Using POST method in XMLHTTPRequest(Ajax)
2008-10-09 17:15
543 查看
var url = "get_data.php";
var params = "lorem=ipsum&name=binny";
http.open("POST", url, true);
//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");
http.onreadystatechange = function() {//Call a function when the state changes.
if(http.readyState == 4 && http.status == 200) {
alert(http.responseText);
}
}
http.send(params);
注意params中值的编码,用函数encodeURIComponent来编码特殊字符。
var params = "lorem=ipsum&name=binny";
http.open("POST", url, true);
//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");
http.onreadystatechange = function() {//Call a function when the state changes.
if(http.readyState == 4 && http.status == 200) {
alert(http.responseText);
}
}
http.send(params);
注意params中值的编码,用函数encodeURIComponent来编码特殊字符。
相关文章推荐
- Ajax using XMLHttpRequest and Struts
- php ajax XMLHttpRequest POST实例代码
- C# post xml using HttpWebRequest/Response
- 最基础的ajax----xmlHttpRequest(get\\post)
- ajax xmlhttprequest使用post传参数并向后台获取数据
- Ajax之二: XMLHttpRequest之POST传递XML (应用环境: Windows + IE + .NET[C#])
- POST a string and an image in one request using HttpClient
- Ajax using XMLHttpRequest and Struts
- Firefox3中使用XMLHttpRequest(Ajax)发送二进制POST数据的简易调试法
- 原始ajax通过xmlHttpRequest对象的send()方法提交数据--Get方式和Post方式
- Java乔晓松-ajax中xmlhttprequest的属性、方法和ajax封装post方法
- post xml using HttpWebRequest/Response
- Ajax 之二: XMLHttpRequest之POST传递XML
- 1.Ajax基础——XMLHttpRequest、Get/Post、封装Ajax
- Ajax & PHP without using the XmlHttpRequest Object
- jQuery的ajax()检验用户名;通过jQuery的load()/get()/post()方法实现;使用XMLHTTPRequest对象来进行AJAX的异步数据交互
- Using XMLHTTP to Post Commands in SharePoint Team Services
- ajax XMLHttpRequest post get
- ajax XMLHttpRequest post get
- ajax中XMLHttpRequest对象的open()方法GET和POST方式区别