ajaxStart() showing loading message doesn't seem to work
I user jquery.ajax call to controller of asp.net mvc... I would like to show a loading indicator.. I tried this but that doesn't seem to work...
<div class="loading" style="padding-left:5px; margin-bottom:5px;display:none;">
Loading... 
</div>
and my jquery ajax call looks like this,
function getMaterials(currentPage) {
$.ajax({
url: "Materials/GetMaterials",
data: {'currentPage': (currentPage + 1) ,'pageSize':5},
contentType: "application/json; charset=utf-8",
global: false,
async: false,
dataType: "json",
success: function(data) {
var divs = '';
$("#ResultsDiv").empty();
$.each(data.Results, function() {
//my logic here....
$(".loading").bind("ajaxStart", function() {
$(this).show();
}).bind("ajaxStop", function() {
开发者_运维百科 $(this).hide();
});
}
});
return false;
}
My loading indicator doen't seem to showup.. ANy suggestion....
using .ajax()
you should just call:
beforeSend: function(xmlHttpRequest){
// show anything here
}
and
complete: function(xmlHttpRequest, status){
// hide it again
}
ajaxStart
and beforeSend
does work for Firefox but not for the all browsers (ie Safari) when we are sending the ajax call with async: false. I'm still finding the way for this
精彩评论