我正在使用Ajax发布内容,并且我使用http.send(encodeURIComponent(params));
进行编码...但我无法在PHP中解码它们。我使用POST,所以我不认为它需要编码?我很困惑,我应该如何在PHP中值解码...decodeURIComponent(uri)不工作?
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));
不,你不会。你想在JavaScript中做到这一点。在PHP中做这件事是不必要的困难和毫无意义的。 – Ryan 2011-05-19 03:43:59
@minitech:okies :)但如何?就像我使用$ username = trim($ _ POST [“username”]); $ password = $ _POST [“password”]; $ ip = trim($ _ POST [“ip”]); $ name = trim($ _ POST [“name”]); $ os = trim($ _ POST [“os”]); $ hostid =“物理”;在PHP如何解码他们...之后,我所有的领域能够采取+和&字符串? – Harsh 2011-05-19 03:46:52
@minitech:我想解码他们在PHP? – Harsh 2011-05-19 03:50:37