$.ajax({
type: "GET",
url: "wordtyping_sql.php",
data: "id=" + id + "&formname=" + formname,
success: function(msg){
alert("Data Saved: " + msg);
}
});
msg
包含從wordtyping_sql.php
三條線分別是:
echo "one";
echo "two";
echo "three";
如何分別得到這個數據?
非常感謝,但是當我添加dataType時發生了一件奇怪的事情:'json',我發現alert()部分不工作,沒有任何東西出來。但如果我評論它,它會再次起作用。你知道原因嗎? – user1969371
好吧,它現在可以工作,我想我沒有工作,我沒有添加json_encode。 – user1969371
但還有一個更重要的問題:爲什麼我無法將reponse.one轉換爲id?請參閱下面的代碼:var id = 80;數據類型:「GET」, url:「wordtyping_sql.php」, data:「id =」+ id +「&formname =」+ formname, dataType:'json',// < ----------------添加了這一行 成功:function(response){ id = response.one; } }); alert(id);爲什麼我會看到與response.one的新值相同的值80 intead? – user1969371