我试图用ajax发送一个html站点,但在服务器端,css的结构已损坏。
我的getInfo函数返回一个带有html文本的变量,看起来像这个
<div id="Center">center<button style="margin-left: 109px; margin-top: -9px; position: absolute;">juhu</button></div>
这个变量,我用ajax发送到我的php页面:
$.ajax({
url:"createFile.php",
type:"post",
dataType:"text",
data:getInfo()
});
但是在服务器站点(php页面)上,post变量的值是:
<div id="Center">center<button absolute;"="" position:="" -9px;="" margin-top:="" 109px;="" style=""margin-left:" xmlns=""http://www.w3.org/1999/xhtml"">juhu</button></div>
怎么了?感谢
如果我没有弄错,这应该可以工作:
$.ajax({
url:"createFile.php",
type:"post",
dataType:"html",
processData:false,
data:getInfo()
});
问题出在反斜杠上。我希望jquery在每个"上添加一个反斜杠。解决方案是php服务器站点上的"stripshases"函数。