As everyone knows, PHP has a $_POST
variable that stores data from POST requests.
I'm trying to use it with XHR..
xhr.send('hey=hello&hi=there');
..but it doesn't work..
echo $_POST['hey'] . ' ' . $_POST['hi']; # The page should say "hello there", but it doesn't.
Am I sending the data incorrectly?
Do I ne开发者_JAVA百科ed to change my php.ini?
How do I get this to work? :(
Most likely the problem is that you're not sending the request with a Content-Type
of application/x-www-form-urlencoded
, so it's getting treated as an unknown chunk of data rather than a set of URL-encoded key/value pairs.
精彩评论