function init(){ test1(); setTimeout("test2()",500);}
但该方法属于投机,并未真正解决问题。
2 修改“XMLHttpRequest创建函数”,改为一实例化函数。
function createXMLHttpRequest() { if (window.ActiveXObject) { var xmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP"); } else if (window.XMLHttpRequest) { var xmlHttpObj = new XMLHttpRequest(); } return xmlHttpObj;}
实例化时相应的改为:
function test1(){ xmlHttp_1 = createXMLHttpRequest(); xmlHttp_1.onreadystatechange = handleStateChange1; url_1 = "test.php?ts=" + new Date().getTime(); xmlHttp_1.open("GET", url, true); xmlHttp_1.send(null);}
function test2(){ xmlHttp_2 = createXMLHttpRequest(); xmlHttp_2.onreadystatechange = handleStateChange1; url_2 = "test.php?ts=" + new Date().getTime(); xmlHttp_2.open("GET", url, true); xmlHttp_2.send(null);}