Ajax响应未返回

I am having a table with data where I have an action button in last column to delete that particular row. I want to make the delete via ajax and without refreshing the page. I am using the following code but their is no response coming from the ajax page. Also the queries at the ajax page is not executing. Can I have some insight over what could be possibly wrong.

      <a href="#" class="btnIcon    glyphicon glyphicon-trash delbutton" data-toggle="tooltip" title="Delete" id="<?php echo $id; ?>"></a>

 <script type="text/javascript" >
        $(function() {

            $(".delbutton").click(function() {
                var del_id = $(this).attr("id");
                var info = 'id=' + del_id;
                var $tr = $(this).closest('tr');

                if (confirm("Sure you want to delete this post? This cannot be undone later.")) {

                    $.ajax({
                        type : "POST",
                        url : "delete_entry.php", //URL to the delete php script
                        data: info,
                    success : function(response) {
                               if(response=='deletion success'){
                                $tr.find('td').fadeOut(1000,function(){ $tr.remove();  }); 

                               }
                        }
                    });  
                }
                return false;
            });
        });
 </script>

And at delete_entry.php

 <?php
header('Content-Type: application/json');  

session_start();

require("../config.php"); 
require("../Database.class.php"); 
require("../site.php"); 
$db = new Database(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE);     
$fnc=new site_functions($db);

    $id     =   $_POST['id'];

    $deleted_date = date("Y-m-d h:i:s");
  $deleted_by       =    $_SESSION['session_admin_id'] ;

  $nots = $db->idToField("tbl_ques","notes",$id);
   if ($nots == "")
   {
   $date_string = "last deleted on|".$deleted_date."|" ;
   }
   else {
   $date_string = $nots."last deleted on|".$deleted_date."|" ;
   }
     $fnc->update_is_not_deleted_for_Pearsonvue("tbl_ques",$id, "$deleted_date", $deleted_by);       
    $notes_data = array("notes"=>$date_string);

  if($db->query_update("tbl_ques", $notes_data, "id=$id")){
      http_response_code();        
      echo json_encode('deletion success');
    }else{
       http_response_code(204);       
    }

?>
查看全部
weixin_33729196
weixin_33729196
2020/01/28 11:37
  • php
  • mysql
  • ajax
  • 点赞
  • 收藏
  • 回答
    私信

1个回复