從我在MDN閱讀參考,它說參數XMLHttpRequest的「真」。開()方法
If TRUE (the default), the execution of the JavaScript
function will continue while the response of the server has not yet arrived.
This is the A in AJAX.
我一直在使用AJAX,但後來我有點迷茫的時候,我讀了。我認爲問題可能是我不清楚AJAX概念清楚..我知道當然AJAX不會刷新頁面,這意味着連接到服務器和響應完全在後臺完成。
但我可以想像根據該引用發生的事情是,如果我在我的JavaScript有這樣的代碼:
//true, therefore process the function while server retrieves url
var xmlResponse;
var url = "http://domain.com/file.xml";
xml_req.open("GET", url, true);
xml_req.onreadystatechange = function() {
if(xml_req.readyState == 4 && xml_req.status == 200) {
if(xml_req.responseText != null)
xmlResponse = xml_req.responseXML; //server response may not yet arrive
else {
alert("failed");
return false;
}
};
xml_req.send(null);
難道這不是意味着xmlResponse可以在這個意義上是不確定的,服務器是仍然檢索數據?有人可以解釋一下AJAX技術的流程是什麼?提前致謝。
您需要更多信息?更多問題? – epascarello
@epascarello:謝謝我認爲我很清楚,thx的幫助。我無法接受兩個答案,但我會先與我回答的人一起 –