1 回答

TA貢獻(xiàn)1757條經(jīng)驗(yàn) 獲得超7個(gè)贊
你有
xmlHttp.open("GET", '/gS', true);
xmlHttp.send(null);
在你的xmlHttp.onreadystatechange回調(diào)函數(shù)中,這會(huì)導(dǎo)致奇怪的效果。
以下代碼(未經(jīng)測(cè)試)應(yīng)該表現(xiàn)得更好:
//AJAX Requests to get
function loadQuestions() {
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", '/gS', true);
xmlHttp.onreadystatechange = function() {
alert(xmlHttp.readyState + " " + xmlHttp.status);
if (xmlHttp.readyState==4 && xmlHttp.status == 200) {
var response = xmlHttp.responseText;
console.log(response);
document.querySelector("#tableQuestions").innerHTML=response;
}
}
xmlHttp.send(null);
}
添加回答
舉報(bào)