gpt4 book ai didi

php - debugURIComponent(uri) 不起作用?

转载 作者:行者123 更新时间:2023-11-28 16:30:47 25 4
gpt4 key购买 nike

我使用 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));

最佳答案

encodeURIComponent 将对所有分隔键/值对的 & 和 = 进行编码。您需要在每个部分单独使用它。就像这样:

 params = 
"guid=" + encodeURIComponent(szguid) +
"&username=" + encodeURIComponent(szusername) +
"&password=" + encodeURIComponent(szpassword) +
"&ip=" + encodeURIComponent(ip) +
"&name=" + encodeURIComponent(name) +
"&os=" + encodeURIComponent(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(params);

关于php - debugURIComponent(uri) 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6053473/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com