我正在尝试将一些 POST 数据 AJAX 到 PHP 页面,但数据未正确发送。我究竟做错了什么?
这是我的代码:
HTML
<a id="some_id">LINK</a>
阿贾克斯函数
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 我得到一个 () 空数组的数组..