读书人

Ajax send ,open 步骤区别

发布时间: 2012-11-07 09:56:10 作者: rapoo

Ajax send ,open 方法区别

(1)用open可以指定get,post

一般情况下,使用Ajax提交的参数多是些简单的字符串,可以直接使用GET方法将要提交的参数写到open方法的url参数中,此时send方法的参数为null。


例如 :

  xmlHttpRequest.open("POST","login.jsp",true);     xmlHttpRequest.setRequestHeder("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");     xmlHttpRequest.send("user="+username+"&pwd="+password);
?

?


?需要注意的是根据提交方式的不同,两种提交方式分别调用后台的doGet方法和doPost方法。

?

?

?

?

<zt> http://andylin02.iteye.com/blog/581035

读书人网 >Ajax

热点推荐