作者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