开发者

Location of information sent by POST to a php file via HTTPRequestObject.send function

开发者 https://www.devze.com 2023-03-31 16:42 出处:网络
Where does the HTTPRequestObject place strings I have sent via \"POST\" to a php file?I have tried looking in the $_POST and $_REQUEST arrays.

Where does the HTTPRequestObject place strings I have sent via "POST" to a php file? I have tried looking in the $_POST and $_REQUEST arrays.

I am 开发者_运维技巧using send like follows:

request.send("name="+name+"&comment="+comment);

from javascript to send data to a php file, where I loose it. The request goes though (I check with onreadystatechange), and I'm using the POST method in my open call.


Try this:

request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

before request.send()

and you should replace:

request.send("name="+name+"&comment="+comment);

with:

request.send("name="+encodeURIComponent(name)+"&comment="+encodeURIComponent(comment));


"form-urlencoded" does not refer to an associative array. I think "request.send("name="+name+"&comment="+comment);" is correct.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号