function createXMLHttpRequest() {
try {
return new XMLHttpRequest();
} catch(e) {
try {
return new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try {
return new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
throw e;
}
}
}
}
window.onload=function (){
//创建,连接,发送请求,接收数据
var xmlHttp=createXMLHttpRequest();
xmlHttp.open("GET","/ajax/PServlet",true);
xmlHttp.send(null);
xmlHttp.onreadystatechange=load(xmlHttp);
};
function load(xmlHttp){
if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
//...
}
}
我在load函数里面使用xmlHttp对象时发现不可以用,请问有什么解决方法呢?