Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/253.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/448.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP';新加坡元邮政不';我不喜欢我发帖的方式_Php_Javascript - Fatal编程技术网

PHP';新加坡元邮政不';我不喜欢我发帖的方式

PHP';新加坡元邮政不';我不喜欢我发帖的方式,php,javascript,Php,Javascript,众所周知,PHP有一个$\uPOST变量,用于存储POST请求中的数据 我正在尝试将其与XHR结合使用 xhr.send('hey=hello&hi=there'); …但它不起作用 echo $_POST['hey'] . ' ' . $_POST['hi']; # The page should say "hello there", but it doesn't. 我是否发送了错误的数据 我需要更改php.ini吗 我怎样才能让它工作(最有可能的问题是,您发送请求时没有使用应用

众所周知,PHP有一个
$\uPOST
变量,用于存储POST请求中的数据

我正在尝试将其与XHR结合使用

xhr.send('hey=hello&hi=there'); 
…但它不起作用

echo $_POST['hey'] . ' ' . $_POST['hi']; # The page should say "hello there", but it doesn't.
我是否发送了错误的数据

我需要更改php.ini吗


我怎样才能让它工作(

最有可能的问题是,您发送请求时没有使用
应用程序/x-www-form-urlencoded
内容类型,因此它被视为一个未知的数据块,而不是一组URL编码的键/值对。

最有可能的问题是,您发送请求时没有使用
内容类型pe
属于
application/x-www-form-urlencoded
,因此它被视为一个未知的数据块,而不是一组URL编码的键/值对。

因此应该
xhr.setRequestHeader('Content-Type','application/x-www-urlencoded'));
修复它?@tyler我写内容类型值时出错。请用
application/x-www-form-urlencoded
再试一次。那么
xhr.setRequestHeader('content-type','application/x-www-urlencoded')也应该如此
修复它?@tyler我写内容类型值时出错。请用
应用程序/x-www-form-urlencoded
再试一次。你有没有看过firebug执行的确切请求?确保
xhr.send
是什么,实际上是以POST模式发送的。@zerkms没有,因为我使用Chrome.)@Renesis我已经检查了几十次请求,它正在使用POST方法。@tylermwashburn:
ctrl+shift+I
then;-)顺便说一句,什么
文件\u获取\u内容('php://input');提供给您?您是否查看了firebug执行的确切请求?请确保无论
xhr.send
是什么,实际上都是以POST模式发送的。@zerkms否,因为我使用Chrome.。)@Renesis我已经检查了几十次请求,它正在使用POST方法。@tylermwashburn:
ctrl+shift+I
then;-)顺便说一句,什么
文件\u获取\u内容('php://input');给你什么?