0

我尝试过但失败的代码。哪里少了点什么……

$(".delete").click(function() 
{
    var db_id = $(this).attr("db_id");
    alert(db_id);
    $.post("ajax_inspection.php", {type: qrystrdelete,id: id},
    function(data)
    {
        // callback function gets executed
        $('#db_id').html(data);
        alert("Return data" + data);
    });

ajax.inspection.php 包含:

<?php
include_once("inspection_query_fun.php");
if($_REQUEST['type'] == 'qrystrdelete')
$var_result = deleteslab($_REQUEST['id']); 
?>

Inspection_query_fun.php 包含 del

<php
function deleteslab($PAR_Id)
{
    $sql = "DELETE FROM ".CONTROL_REPORT_DETAILS." WHERE sb_slab_id=".db_escape($PAR_Id);
    db_query($sql);
}
?>
4

2 回答 2

5

改变

$.post("ajax_inspection.php", {type: qrystrdelete,id: id}

对此:

$.post("ajax_inspection.php", {type: "qrystrdelete",id: db_id}
于 2013-02-15T14:54:00.223 回答
1

可能您需要在以下几行中进行一些编辑:

 var db_id = $(this).attr("db_id");
       alert(db_id);
       $.post("ajax_inspection.php", {type: qrystrdelete,id: id},

将其替换为以下内容:

 var id = $(this).attr("id");
       $.post("ajax_inspection.php", {type: "qrystrdelete",id: id},

希望这会奏效。

于 2013-02-15T15:02:37.860 回答