我以这种方式使用 ajax $post 调用删除了我的记录
HTML
$btn = "<input type='button' ";
$btn .= "url='$_SERVER[REQUEST_URI]' idric='$row[id_ric]' ancor='#LR'";
$btn .= "class='deletr ttip' />";
查询
$(".delete").click(function(){
var ancor = $(this).attr('ancor');
var url = $(this).attr('url');
var idric = $(this).attr('idric');
var url = url + ancor;
$.post("testpost.php", {url:url, idric:idric}, function(data){
location.reload();
});
});
testpost.ph
//class delete
$obj->delete($_POST['id_ric']);
通过对话框确认后,我想删除一条记录。我以这种方式尝试过,但没有成功。
$(".delete").click(function(){
html_msg = "Are u sure?";
var ancor = $(this).attr('ancor');
var url = $(this).attr('url');
var idric = $(this).attr('idric');
var url = url + ancor;
$('#confirm').dialog('open').html(html_msg);
});
$("#confirm").dialog({
resizable: false,
autoOpen: false,
modal: true,
dialogClass: 'confirm',
buttons: {
Yes: function() {
$(this).dialog( "close" );
testdelete();
},
No: function() {
$(this).dialog( "close" );
}
}
});
function testdelete(){
$.post("testpost.php", {url:url, idric:idric}, function(data){
//location.reload();
alert("ok");
});
}
我怎么能这样做?谢谢