debugURIComponent(uri) 不起作用?
我使用 Ajax 发布内容,并使用 http.send(encodeURIComponent(params));
进行编码...但我无法在 PHP 中解码它们。我正在使用 POST,所以我认为它不需要编码?我对如何解码 PHP 中的值感到困惑......
params = "guid="+szguid+"&username="+szusername+"&password="+szpassword+"&ip="+ip+"&name="+name+"&os="+os;
//alert(params);
document.body.style.cursor = 'wait';//change cursor to wait
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(encodeURIComponent(params));
I'm using Ajax to post contents, and I'm using http.send(encodeURIComponent(params));
for encoding ... but I'm unable to decode them in PHP. I'm using POST so I didn't think it required encode? I'm confused as to how I'm supposed to decode the values in PHP...
params = "guid="+szguid+"&username="+szusername+"&password="+szpassword+"&ip="+ip+"&name="+name+"&os="+os;
//alert(params);
document.body.style.cursor = 'wait';//change cursor to wait
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(encodeURIComponent(params));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
encodeURIComponent
将对所有分隔键/值对的 & 和 = 进行编码。您需要在每个部分单独使用它。就像这样:encodeURIComponent
will encode all the &s and =s that delimit your key/value pairs. You need to use it on each part individually. Like so:如果您从 JS 提交编码值并希望在 PHP 中
解码
它们,您可以执行以下操作:If you're submitting encoded values from JS and want to
decode
them in PHP you can do something like: