Is it possible in JQuery to cancel a .load() before making any changes to the html element?
For instance:
$(".userElementsList").load("/userList/addNewUser",
params,
function (responseText, textStatus, jqXHR) {
try {
var response = $.parseJSON(responseText);
alert(response.message);
$(". userElementsList").off();
} catch (error) {
cleanningUserPopupData();
$("#userPopup").modal("hide");
}
}
);
I have a page with a table and a popup that allows to create users, when the user clicks in create the code above is executed. If there isn't any errors it should return a html content to build the users table in the page, but in case of any error occurs it returns a json content with the error to show in the popup.