私は次のようなものを持っています:
$(".remove-item").click(function(e) {
e.preventDefault();
var url = $(this).attr('href');
var id = $(this).data("id");
$.when(removeItem(url))
.then(removeItemResponse(id));
});
var removeItemResponse = function(data, id) {
console.log(data);
console.log(id);
};
var removeItem = function(url) {
return $.post(url);
};
上記は、ajax リクエストが処理された後にログに何も記録されないという点で機能しておらず、removeItemResponse で引数を処理する方法と関係があることがわかっています。ajax 投稿から返されたデータを使用する必要がありますが、クリック関数で取得した ID も渡す必要があります。