ajax请求

 

原声实例

var result = null;//在不知道值是什么类型的时候  可以通过null去赋值
var rep = new XMLHttpRequest?new XMLHttpRequest():new ActiveXObject();
rep.open("GET","http://route.showapi.com/255-1?showapi_appid=40091&showapi_sign=2b66a43022b444ad81e18ad18996cefc",false);
rep.onreadystatechange=function(){
    alert(this.readyState);
        if(this.readyState===4){
        alert("交互完成")
        result = rep.response;
    }
};
rep.send();

document.write(result)

 

 

上一篇:跨域


下一篇:Java中的Volatile和synchronized的区别