ajax url不调用php文件

时间:2019-05-16 20:20:01

标签: php ajax

您好,我只是想使用Ajax URL来调用我的My delete.php文件,但我没有调用php页面。我重新启动成功功能但未到达php page。请检查我的代码。

==> View.php

   $(document).on("click", "#delBtn", function(){ 
    var id = $(this).closest('tr').attr('id');
    $.ajax({
        type: 'POST',
        url : 'delete.php',
        data:id,
        success: function () {
          alert("Deleted Successfully");
        },
          error: function(xhr, textStatus, error){
            alert(xhr.statusText);
            alert(textStatus);
            alert(error);
          }
    });
 });

==> delete.php

        <?php

        include_once('database/db.php');
          if(isset($_POST['id'])){

          $id = $_POST['id'];
          var_dump($id);
           exit();
        $getUsers = $connect->prepare("DELETE FROM registration WHERE id = 
         '".$id."' ");
          $getUsers->execute();

       }
       ?>

1 个答案:

答案 0 :(得分:0)

使用密钥/对,然后将数据发送到php文件。并且在使用$ _POST ['key']的Php文件中,您可以检索值。

相关问题