Jump to content

Jquery Ajax Doesn't Have Ready States!


MrFish
 Share

Recommended Posts

How can I show that ajax is loading something when I cannot use ready states? I'm currently using-

$.get(page+".html", function(data){	 // Do something with the data});

How can I show that ajax is working?

Link to comment
Share on other sites

You can chain the .ajaxStart(function() { ... }) handler to an element. Perhaps you want to create a div with some text or a gif. Also chain the .ajaxStop(function() { ... }) handler to trigger something when it's done. The example in the book I have here is:

$(document).ready(function() {$('div id="loading">Loading...</div>').insertBefore('#dictionary').ajaxStart(function() {$(this).show();}).ajaxStop(function() {$(this).hide();});});

That function obviously creates a div which is shown when ajax calls (any ajax calls anywhere) start and hidden when it's finished.

Edited by chibineku
Link to comment
Share on other sites

It sure is, yeah.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...