Location of information sent by POST to a php file via HTTPRequestObject.send function
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.
精彩评论