作者a1989198 (天才櫻木)
看板Ajax
標題[ajax] 關於使用$.ajax將一段html 傳到後端php
時間Fri Oct 30 17:01:18 2009
請問一下
我在a.html將一段html 例如
<div class="ajax1"></div>.....
$.ajax({
url: 'b.php',
dataType: 'html',
type:'GET',
data: { name: wordResult},
error: function(xhr) {
alert('Ajax request 發生錯誤');
},
success: function(
txt) {
alert(
txt);
}
});
利用$.ajax傳到b.php回傳之後
alert的 內容竟然 變成<div class="
\ajax1
\"></div>.....
他在""的裡面的前後都加了一個"\"
有人知道為什麼嗎@@?
請幫我解惑 感謝> <
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.115.82.11
※ 編輯: a1989198 來自: 140.115.82.11 (10/30 17:02)
1F:推 adamp3:escape 10/30 19:07
2F:→ a1989198:我試著用PREG_REPLACE 可是消不掉 10/30 19:45
3F:推 buganini:你的php大概開了magic_quotes 你可以用stripslashes 10/31 02:11
4F:→ buganini:或把magic_quotes關掉.. 10/31 02:11
5F:→ a1989198:感謝 用stripslashes 解決了~︿﹍︿ 10/31 21:46
6F:推 buganini:你這樣寫 可能搬到別台就不會動了喔.. 11/01 00:27