您的位置:首页 > 其它

AjAx使用方法四步骤,创建,打开,发送,onreadystatechange

2017-07-13 08:55 363 查看

AjAx使用方法四步骤,

创建,

打开,

发送,

onreadystatechange

//创建对象
xhr=new XMLHttpRequest();
//打开  open ()括号里面三个参数,1:method  2:地址  3:true 或 false;
tx1=xhr.open('GET','http://122.114.29.94/index.php?name=',true);
//发送 send  ()括号里面的值  GET 的时候是  null   可以写或者不写;
xhr.send();
//onreadystatechange
xhr.onreadystatechange=function(){
if(xhr.readyState==4  && xhr.status==200){
console.log("成功进来了")

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息