last day (14 days later) » 

11:22 AM
0
Q: Loading image with large ajax responce

ShinI have added the following code to show and hide loading image in my web page during ajax request. $(document).ajaxStart(function(){ $("#please_wait").css("display","block"); }); $(document).ajaxComplete(function(){ $("#please_wait").css("display","none"); }); Here, $("#please_wait...

 
Do you have multiple ajax requests on your site? ajaxComplete may be fired from any other request.
 
@secelite ,yes,This is the common function i was used to show loader.
@Giannis,Ya,That was the problem,I was trying to find a methow to complete data transfer.
 
@Shin so is it possible that you have more than one simultaneously requests and the ajaxComplete is fired before finishing your "huge" request?
 
@secelite How to handle tthis situation?
 
@Shin you could count up an internal variable like ajaxCount wirth every ajaxStart you fire. In ajaxComplete you can subtract from ajaxCount. If it is 0 you can execute your callback $("#please_wait").css("display","none");
 
11:22 AM
hi
 
hi
 
finaly i remove $(document).ajaxComplete
complete:function(){}
added for each ajax request
 
Ah, so you loop through the requests?
 
no
it is called in $.ajax()
 
Ok, is it working then now? Have you tried my suggested solution?
 
11:41 AM
ya
but there are more requests
so,I think it is not better for me
 
It's hard to imagine your situation for this. So if I understand you right, you have multiple requests like ReA and ReqB. ReqA is called and 1 second later ReqB is fired. Both trigger ajaxStart. ReqA is finished after 5 seconds and triggers ajaxComplete. So the please wait message is dismissed although ReqB is not finished.
Is that right?
 

last day (14 days later) »