【发布时间】:2016-07-24 21:20:08
【问题描述】:
我正在尝试使用 ajax 删除 mysql 的记录。一切正常。但是当我单击垃圾按钮时,我还想向按钮添加加载。下面是我的按钮链接
<a href="#" id="delpost" data-id="'.$row['id'].'" class="btn btn-default pull-right" title="Delete"><i class="fa fa-trash-o"></i></a>
下面是我的ajax
$(function() {
$('body').on('click', '#delpost', function() {
var del_id = $(this).attr("data-id");
var info = 'id=' + del_id;
var parent = $(this).closest('li');
var btn = $(this);
btn.button('loading');
if (confirm("Sure you want to delete this Post? There is NO undo!")) {
$.ajax({
type: "POST",
url: "/delete-post.php",
data: info,
beforeSend: function() {
parent.animate({
'backgroundColor': '#fb6c6c'
}, 300);
},
success: function() {
btn.button('reset');
parent.slideUp(300, function() {
parent.remove();
});
}
});
}
return false;
});
});
【问题讨论】:
-
抱歉,问题出在哪里?
-
你可以使用类似this
标签: php jquery ajax twitter-bootstrap