无法通过 AJAX/Fancybox POST 数据到 PHP 文件

Can't POST data through AJAX/Fancybox to PHP file

嘿,我无法通过 AJAX 将 JS 变量传递到 php 文件。无论我尝试 POST 还是 GET 它都不起作用:使用 POST 它给了我 [] 或未定义的索引,如果我想 print_r($_POST['adminID'] 然后得到,我得到 {"fancybox":"true"}

$('#adminList tr').on('click', function() {
    var adminID = $(this).find(".adminID").text(); 
    console.log(adminID);
    $.ajax({
           type: 'POST',
           url: 'modules/management/user_edit.php',
           data: {adminID : adminID}, 
           success: function(data)
           {
                $.fancybox.open({
                src  : 'modules/management/user_edit.php',
                type : 'ajax'
                });
           }
    });
 });

和module/management/user_edit.php我只想post这个adminID

您向 user_edit.php 文件发送了两次请求,第一次有 POST 数据,第二次没有。您应该在 fancybox 中显示第一个请求的结果。

$('#adminList tr').on('click', function() {
    var adminID = $(this).find(".adminID").text(); 
    $.ajax({
           type: 'POST',
           url: 'modules/management/user_edit.php',
           data: {adminID : adminID}, 
           success: function(response)
           {
                $.fancybox.open(response);
           }
    });
 });