我正在通过AJAX to a PHP script
并使用此代码
if(!http)
http = CreateObject();
nocache = Math.random();
http.open('post', 'addvm.php');
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");
http.onreadystatechange = SaveReply;
http.send(params);
问题是任何+ and &
标志都被剥离并被替换。如何安全地“编码”+ and &
符号,然后在PHP端对其进行适当的'解码'?
答案 0 :(得分:2)
尝试:
js:encodeURIComponent (/* url */);
php:urldecode (/* url */);
答案 1 :(得分:2)
需要编码你的参数encodeURIComponent
注意: - 当您访问$_GET, $_POST or $_REQUEST in PHP
时,您正在检索已经解码的值。