【发布时间】:2014-12-22 22:16:55
【问题描述】:
我正在尝试通过 POST 方法通过 AJAX 将数据发送到 php。 PHP代码:
<?php
print_r($_POST);
JavaScript 代码:
var xml = new XMLHttpRequest();
xml.open("POST", "test.php", false);
xml.send("a=X");
document.write(xml.responseText);
结果是:
Array ( )
为什么不在数组 [a] => "X" 中?数组每次都是空的。我在 Apache 2.4.10 (XAMPP v3.2.1) 上使用 PHP 5.6.3。
【问题讨论】:
-
什么是
test.php打印? -
空数组
Array ( )
标签: javascript php arrays ajax post