0

我的操作是:

var SimTxt = "some text & some other text";
...
xmlhttp.send(&SimTxt ="+SimTxt);
...

<?php 
$SimTxt = $_POST['SimTxt'];

echo

 <button id="btn9" class="sim_btn" type="button">
 '.$simBtn10.'
 </button>

但是屏幕上的printet只是删除“&”符号后的“一些文本”

4

1 回答 1

4

您的字符串需要在发送之前进行编码:

..
var SimTxt = encodeURIComponnent("some text & some other text");
xmlhttp.send(&SimTxt ="+SimTxt);
...

-- 并且字符串(实际上被视为参数,因此被 分割&),不会被 PHP 视为 URI 组件。

于 2013-09-23T10:25:29.157 回答