2015年10月28日
Ajax
alert(a);
//Error,这是一个没有定义的变量。
alert(window.a);
//underfined,,没有定义的属性。function ajax(url,fnSucc,fnFaild){
var oAjax=new XMLHttpRequest()|| new ActiveXObject("Microsoft.XMLHTTP");
//连接服务器,
//open(方法,文件名,异步传输)
oAjax.open('GET', url,true)
//发送请求
oAjax.send();
//接受返回
oAjax.onreadystatechange=function(){
//oAjax.readyState 浏览器和服务器,进行到哪一步。
if(oAjax.readyState==4)//读取完成,代表交互已经完成了。
{
if (oAjax.status==200) {//读取后可以正常解析。
fnSucc(oAjax.responseText);
}else{
if(fnFaild){
fnFaild(oAjax.status);
}
}
}
}
}cookie
Last updated