AJAX noob here...所以下面的这段代码适用于我,它在 onclick 事件期间被调用:
function updateText() {
var http = getHTTPObject();
http.open("GET","ajax_info.asp",true);
http.onreadystatechange = function() {
if (http.readyState == 4) {
document.getElementById("myDiv").innerHTML=http.responseText;
}
}
http.send();
}
但是,当我尝试像下面这样清洁它时,它不再起作用。下面的代码不是正确的回调语法吗?
function handleHTTPResponse() {
if (http.readyState == 4) {
document.getElementById("myDiv").innerHTML=http.responseText;
}
}
function updateText() {
var http = getHTTPObject();
http.open("GET","ajax_info.asp",true);
http.onreadystatechange = handleHTTPResponse;
http.send();
}