[ajax] 關於使用$.ajax將一段html 傳到後端php

看板Ajax作者 (天才櫻木)時間16年前 (2009/10/30 17:01), 編輯推噓3(303)
留言6則, 3人參與, 最新討論串1/1
請問一下 我在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)

10/30 19:07, , 1F
escape
10/30 19:07, 1F

10/30 19:45, , 2F
我試著用PREG_REPLACE 可是消不掉
10/30 19:45, 2F

10/31 02:11, , 3F
你的php大概開了magic_quotes 你可以用stripslashes
10/31 02:11, 3F

10/31 02:11, , 4F
或把magic_quotes關掉..
10/31 02:11, 4F

10/31 21:46, , 5F
感謝 用stripslashes 解決了~︿﹍︿
10/31 21:46, 5F

11/01 00:27, , 6F
你這樣寫 可能搬到別台就不會動了喔..
11/01 00:27, 6F
文章代碼(AID): #1AwgjWUa (Ajax)
文章代碼(AID): #1AwgjWUa (Ajax)