0

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="\&quot;margin-left:" xmlns="\&quot;http://www.w3.org/1999/xhtml\&quot;">juhu</button></div>

なにが問題ですか?ありがとう

4

2 に答える 2

0

問題はバックスラッシュでした。私は jquery がすべての " " " にバックスラッシュを追加することを考えています。解決策は、php サーバー サイトの "stripslashes" 関数でした。

于 2013-08-12T10:32:29.213 に答える
0

私が間違っていなければ、これはうまくいくはずです:

$.ajax({
url:"createFile.php",
type:"post",
dataType:"html",
processData:false,
data:getInfo()
});
于 2013-08-10T18:14:30.007 に答える