xmlhttp.open("POST", "url", true)
在尝试通过(javascript)向服务器发送 POST 请求时,我得到一个空的$_POST array
.
Firebug 显示正在发送数据。这是来自 Firebug 的数据字符串:a=1&q=151a45a150...
。但$_POST['q']
什么也不返回。
有趣的是,它file_get_contents('php://input')
确实有我的数据(上面的字符串),但 PHP 不知何故无法识别它。尝试了 $_POST 和 $_REQUEST,没有任何效果。
正在发送的标头:
POST /test.php HTTP/1.1
Host: website.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Referer: http://website.com/
Content-Length: 156
Content-Type: text/plain; charset=UTF-8
Pragma: no-cache
Cache-Control: no-cache
感谢您的任何建议。