第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

AJAX 正在返回 readystate=1

AJAX 正在返回 readystate=1

慕萊塢森 2023-05-25 15:43:57
我正在使用 Flask 和 Python。從 Flask 方法中,我試圖在 AJAX 調(diào)用中返回 HTML 表格行。HTML 頁面有:<div><table id="tableQuestions"></table>//AJAX Requests to getfunction loadQuestions() {  var xmlHttp = new XMLHttpRequest();   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.open("GET", '/gS', true);   xmlHttp.send(null);  }}Flask 路線有:#test.mix() returns html table rows@gbp.route('/gS')def gS():    test=mn()    response = make_response(test.mix(quesCount=4),200)    response.mimetype="text/html"在 Safari 調(diào)試器中,我可以看到有responseText來自服務(wù)器的表數(shù)據(jù),但readystate仍然是 1 和status= 0。你能建議我如何克服這個(gè)問題嗎?
查看完整描述

1 回答

?
長風(fēng)秋雁

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);

}


查看完整回答
反對(duì) 回復(fù) 2023-05-25
  • 1 回答
  • 0 關(guān)注
  • 216 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)