我的代码很简单。我的onReadyStateChange永远不会被调用,为什么?
function useXMLHttpRequest() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", "test.ashx", false);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
xmlhttp.onReadyStateChange = function() {
alert("ss");
};
xmlhttp.send("i=5");
alert(xmlhttp.responseText);
}
当我打电话useXMLHttpRequest.Yes,它就会提醒xmlhttp.responseText的价值。但它不警告(“ss”)。在IE9和Firefox中。 任何人都可以告诉我什么是worng?
是的,我发布这个问题后,我发布这个问题。什么是愚蠢的我。 –