编程语言
首页 > 编程语言> > JavaScript AJAX

JavaScript AJAX

作者:互联网


var xhr = new XMLHttpRequest();
xhr.open("POST", "http://www.baidu.com", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function()
{
    if(xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 304))
    {
        console.log(xhr.responseText);
    }
};
xhr.send("id=1&name=xmsb");

 

标签:status,function,www,XMLHttpRequest,JavaScript,xhr,AJAX
来源: https://www.cnblogs.com/XiaoMingBlingBling/p/16348654.html