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

来源:互联网 发布:双汇系统网址知多少 编辑:程序博客网 时间:2024/06/06 01:05

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();//onreadystatechangexhr.onreadystatechange=function(){if(xhr.readyState==4  && xhr.status==200){console.log("成功进来了")}