I am trying to delete a row in database when an a
element is removed, with backspace, delete key... But this event is never fired. Also, is it possible in any way to save the id just before it is removed?
$('a').on('remove', function () {
var aId = $(this).attr('id');
$.ajax({
url:'/annotations/' + aId,
method: 'DELETE',
headers: {'X-CSRF-Token': csrf_token},
dataType: 'json',
success: function (response) {
console.log("SUCCESS: " + response);
},
error: function (jqXHR, exception) {
var msg = '';
if (jqXHR.status === 0) {
msg = 'Not connect.\n Verify Network.';
} else if (jqXHR.status == 404) {
msg = 'Requested page not found. [404]';
} else if (jqXHR.status == 500) {
msg = 'Internal Server Error [500].';
} else if (exception === 'parsererror') {
msg = 'Requested JSON parse failed.';
} else if (exception === 'timeout') {
msg = 'Time out error.';
} else if (exception === 'abort') {
msg = 'Ajax request aborted.';
} else {
msg = 'Uncaught Error.\n' + jqXHR.responseText;
}
console.log("ERROR: " + msg);
},
});
});