【发布时间】:2013-04-26 09:34:59
【问题描述】:
我正在尝试将一些 POST 数据 AJAX 到 PHP 页面,但数据未正确发送。我做错了什么?
这是我的代码:
HTML
<a id="some_id">LINK</a>
Ajax 函数
mFunction(){
$("#some_id").click(function(){
var thisId = $(this).attr('id');
console.log(thisId);
$.ajax({
type : 'POST',
url : 'magic.php',
data: {"thisId" : thisId},
dataType: "json",
success:function(data){
console.log(data);
}
});
});
}
PHP
<?php$thatId = $_POST['thisId'];
print_r($_POST);
?>
所以一切都应该按照我的理解进行,但是有问题。 在 console.log(data) 我获取 ID 所以数据已经发送 但是在 print_r 我得到一个 () 空数组的数组..
【问题讨论】:
-
而PHP部分在哪里?
-
<?php$thatId = $_POST['thisId']; print_r($_POST); ?> -
您确定
P是variables_order的一部分吗?