代码我尝试过但失败了。某处缺少某些东西......
$(".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);
}
?>
答案 0 :(得分:5)
更改
$.post("ajax_inspection.php", {type: qrystrdelete,id: id}
到此:
$.post("ajax_inspection.php", {type: "qrystrdelete",id: db_id}
答案 1 :(得分: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},
希望这会奏效。