Ajax之Post理解

来源:互联网 发布:qq农场鱼塘升级数据 编辑:程序博客网 时间:2024/05/20 20:57

代码:

 xmlHttp.open("POST", url, true);

    xmlHttp.onreadystatechange = handleStateChange;

    xmlHttp.setRequestHeader("Content-Type",

                  "application/x-www-form-urlencoded;");

    xmlHttp.send(queryString);

为了确保服务器知道请求体中有请求参数,需要调用setRequestHeader,将Content-Type值设置为application/x- www-form-urlencoded。最后,调用send()方法,并把查询串作为参数传递给这个方法。