我的操作是:
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>
但是屏幕上的打印只是"一些文本",删除"&"符号后的所有内容
您的字符串需要在发送之前进行编码:
..
var SimTxt = encodeURIComponnent("some text & some other text");
xmlhttp.send(&SimTxt ="+SimTxt);
...
-- 并且字符串(实际上被视为参数,因此被 &
分割),PHP 不会将其视为 URI 组件。