我正在使用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