Use a loading for ajax requests. This link will help you choose a loading of your choice: link
Here is an example of how you could put a global loading in your ajax call.
<div class="load">
<div class="img/load.gif"></div>
</div>
$(document).ajaxStop(function() {
Block(false);
});
$(document).ajaxStart(function() {
Block(true);
});
function Block(status) {
if (status) {
$(".load").show();
} else {
$(".load").hide();
}
}
Calling Ajax
Block(true);
$.ajax({
url: '@Url.Action("", "")',
data: {
id: id
},
type: 'POST',
success: function(response) {
Block(false);
},
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(msg);
}
});