看板 Ajax 關於我們 聯絡資訊
callback的值 可以alert出來 (下例中,可alert ok, wrong,但無法alert 1,2) 不過怎麼不能用==呢 那要怎麼知道裡面的值是什麼 $.ajax({ url: "../login.do", cache: false, data: dataValue, dataType: "text", success: function(msg){ if(msg=="ok"){ alert("1"); } if(msg=="wrong"){ alert("2"); } alert(msg); } }); -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.116.40.183 ※ 編輯: tomin 來自: 122.116.40.183 (07/15 15:12)
KiroKu:msg.responseText才會是字串吧? 07/15 15:15
tomin:我試試 document找不太到說明 07/15 15:34
tomin:試不出來耶 msg預設是html 我指定text了啊 07/15 16:38
tomin:1樓的msg是xml或json? 07/15 16:38
KiroKu:success的接收參數應該是 一個object不是單純的string 07/15 19:02
KiroKu:alert(msg);實際上會變成是alert(msg.toString()); 07/15 19:03
KiroKu:因為alert參數必須是string msg這個object會被自動轉string 07/15 19:07
tomin:我也猜它不單純 但我用if(msg.toString()=="wrong")也不行 07/15 20:00
KiroKu:或是你傳回了其他字元?用indexOf()看看? 07/15 21:52
tomin:暫時不想管它了 以後遇到再說 07/16 00:33