Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Friends !

I am blocked somewhere in project with implementing Loading Spinner during java-script ajax request.

I am loading some data from database using java-script ajax call and need to put loading spinner white request is in progress. The ajax request takes a bit time as data is bulk hence program control skip the request and process for next code statement. And in next code block i am using response of ajax call as data object. So data is unavailable yet and it throws an error. But for the same time loading spinner works.

I tried to set async : false, in ajax call but this time me loading spinner does not works as program controller first process ajax request and than other request.

I have tried to put that loading spinner call before ajax call but it is not working.

Is there any way where i can achieve both of functionality.

Thank you very much in advance for your help.


~Regards !

Chandrakant
Posted
Comments
Moykn 13-Nov-13 6:45am    
Have you tried using jQuery's beforeSend and complete callbacks to handle the display state of your loading. If you need further help, you should post some o the code(Html and javascript) you are using.

1 solution

This is achieved simply by using ajaxStart() and ajaxStop() methods.

$( document ).ajaxStart(function() {
$( "#loading" ).show();
});

$( document ).ajaxStop(function() {
$( "#loading" ).hide();
});


...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900