You call $.ajax .
In lines
$.ajax(options).success(function(data)... $.ajax(options).error(function(data)...
you are actually making two different AJAX calls β one with a success callback and the other with an error callback.
In your case, your call should look like this:
var options = { type: "GET", url: href, data: { menuRoleId: menuRoleId } }; $.ajax(options) .success(function (data) { spinner.toggle(false); $(".modal-body").html(data); $(".modal").modal({ backdrop: 'static' }); }) .error(function (data) { spinner.toggle(false); toastr.error("Oops..Some thing gone wrong"); }); return false;
It will set both callbacks to a single AJAX call and execute it.
source share