I have something like the following:
$(".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);
};
The above isn't working in that I get nothing in the logs after the ajax request is processed and I know it has something to do with how I'm addressing the arguments in removeItemResponse. I need to use the returned data from the ajax post but also pass in the id I retrieved in the click function.
removeItemdefined?removeItemis relevant. Knowing how it is defined won't help with passingidthrough to the .then callback fn.