您好。
我正试图从一个php文件(manage.php)向另一个php文件(view.php)发送一小段简单的数据。
我无法通过表单发送数据,我想通过JS脚本发送数据。这是我的尝试:
var read = function(id) {
xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", "view.php", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send("id=" + id);
}
在view.php文件中,使用$_POST["id"]会导致错误,提示索引"id"未定义。
正确的数据发送方式是什么?谢谢。
print_r($_POST)
或者print_r($_REQUEST)
的输出中看到了吗? - doublesharp