Jump to content

Jquery Ajax Doesn't Have Ready States!


MrFish

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.

Link to comment
Share on other sites

It sure is, yeah.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...