一个关于XMLHttprequest异步问题
为什么当XMLHTTPREQUEST的OPEN()方法内,设置异步true且用POST进行提交时,,当 SEND()方法参数不为NULL时,在IE下,有时候获取到服务器返回值会变成空?而有时候又能取到正确值,在其他浏览器就不会?跪求大虾们帮帮忙
[解决办法]
function createXMLHttpRequest() {var xmlHttp = null;if (window.XMLHttpRequest) { xmlHttp = new XMLHttpRequest();}else if (window.ActiveXObject) { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP")}if (xmlHttp == null) returndata = "a=1&b=1"xmlHttp.onreadystatechange = handleStateChange;xmlHttp.open("POST", "simpleResponse.ashx?tmp=" + (new Date()).valueOf(), true);xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");xmlHttp.setRequestHeader("Content-length", data.length);xmlHttp.setRequestHeader("Connection", "close");xmlHttp.send(data);}function handleStateChange() {if (xmlHttp.readyState == 4) { if (xmlHttp.status == 200) { alert(xmlHttp.responseText); }}}