开发者

PHP's $_POST doesn't like how I post

开发者 https://www.devze.com 2023-03-20 02:00 出处:网络
As everyone knows, PHP has a $_POST variable that stores data from POST requests. I\'m trying to use it with XHR..

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.

0

精彩评论

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