ajaxを使用してmysqlのレコードを削除しようとしています。すべてがうまくいきます。しかし、私はまた、ゴミ箱のボタンをクリックすると、ボタンにローディングを追加したい。以下の私のボタンのリンクブートストラップボタンをAjaxでロードする
<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;
});
});
申し訳ありませんが、質問はどこにありますか? – WhoAmI
[this](http://msurguy.github.io/ladda-bootstrap/)のようなものを使用できます –