读者的进步速度远大于博客的进步速度。
2008年07月30日Ajax

没有评论
42 views

关于XMLHttpRequest的get和post方式提交.

众所周知XMLHttpRequest的open()方法里的第一个参数是用来设置向服务器提交的方式,这是绝对的吗?不一定哦,看看下面的代码。
代码片断如下:
function simpleStrSubmit()
{
var xmlReqFile = createXMLReqFile();
xmlHttp.open(“GET”,”ProcessServlet”,true);//指定GET方式提交
xmlHttp.onreadystatechange = processRequest;//回调函数
xmlHttp.setRequestHeader(“Content-Type”,”application/x-www-form-urlencoded”);
xmlHttp.send(“xml=”+xmlReqFile);
}
描述:其中ProcessServlet是一个Servlet
问题:open方法的第一个参数不论写”GET”或是”POST”,在ProcessServlet里都是调用的doPost方法??这是为什么?为什么不调用doGet方法???
答案:按照哪种方式提交不是由open()方法的第一个参数完全决定的,还与send()方法有关。
[color=Red] 一、当open()方法里指定的是GET,并且
1、send()方法的参数是”"或者null,跟踪代码可以知道调用了Servlet中的doGet方法
2、send()方法的参数是地址重写的方式,或者就是一个字符串,都调用doPost方法,例如:
xmlHttp.open(“GET”,
“ProcessServlet?choose=”+document.getElementById(“choosejsfile”).value,
true);//open里调用GET方法。
xmlHttp.send(“aaa=dd”); //a
xmlHttp.send(“paramTest”); //b
xmlHttp.send(” “); //c
xmlHttp.send(null); //d
xmlHttp.send(“”); //e
对于a、b、c、d、e五中send()函数,只有d和e会调用doGet方法,a、b、c三种方式均调用 doPost方法。
[color=Red] 二、当open()方法里指定的是POST,则对于以上5种send()函数,服务器均会调用doPost方法。
所以使用哪种方式提交是由open方法和send方法共同决定的。

2008年07月29日Software & Success

没有评论
48 views

想在你的网站上显示我的最新文章吗?

这是一款widget 。
只要把我生成的代码 贴到你的网站上,就可以随时浏览我更新的内容了。
Flash的:

JS的:

jQuery—表格操作.

演示:

http://www.cssrain.cn/demo/hidetabletr.html

jQuery—美化表单操作.

演示:

http://www.cssrain.cn/demo/ContextHighlighting.html

jQuery插件—美化多选框和单选框.


演示:

http://www.cssrain.cn/demo/prettyCheckboxes/prettyCheckboxes.html

下载:

http://www.cssrain.cn/demo/prettyCheckboxes/prettyCheckboxes.rar

jQuery—去掉超链接虚线框.


加上这段:
[code]

[/code]

Mootools插件—context menu(右键菜单)


How to use it?
1 , Download mootools.ddmenu.v1.js and ddmenu.css. Include them in your page



2, Create the menu-HTML width the items and they're IDs

[b]
3, Initialize ddMenu class passing the options. This example calls console.info when a menu item is clicked. (Take a look in the JS-Source for more informations) [/b]
function iniz () {
pagemenu = new DDMenu ('ddmenu2', document, { //document can be the whole page,
//an element or a parent of elements
onOpen: function (e) {
this.enableItems(true); //enable all
this.enableItems('menu_item_with_icon2',false); //disable menu_item_with_icon2
},
onItemSelect: function (act_id, act_el, menu_bindon) {
console.info(“menu action -> item id: \”%s\” from: %o in %o”, act_id, act_el, menu_bindon)
}
});
}
下载:

http://netjard.de/labs/ddmenu/index.html

2008年07月28日TeamWork

4条评论
56 views

jQuery书籍—第一章.

第一章终于写出来了,
写这些东西真是累,反反复复进行了N次。
希望读者能够喜欢。
http://www.cssrain.cn/demo/lab/第一章.htm
感谢小飞和小天 一起编写。

jQuery插件—LivejQuery。

很早就看过这款插件,那时候不知道干什么的。
现在知道了。
下面我来讲解下:
首先看demo1:

http://www.cssrain.cn/demo/livejquery/notalert.html

发现动态增加的 ,不弹出警告框。
然后看demo2:

http://www.cssrain.cn/demo/livejquery/alert0.html

虽然弹出来了,但必须跟在append后面写。
最后看livejquery插件:

http://www.cssrain.cn/demo/livejquery/alert.html

能弹出警告框,不需要跟在append后写。
直接
[code]$('div').livequery('click',function(){
alert("suc");
});[/code]
说到这里,你应该明白, 我为什么要推荐这个插件!
动态增加内容是经常要做的事情。这个插件能帮助我们。
官方站点是:http://brandonaaron.net/docs/livequery/

jQuery—列表切换效果.

带自动切换,手动切换,3种切换效果。

演示;

http://www.cssrain.cn/demo/byzuo/arrow.html

下载,直接查看源文件

返回顶部