MrFish Posted October 11, 2009 Share Posted October 11, 2009 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 More sharing options...
chibineku Posted October 11, 2009 Share Posted October 11, 2009 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 More sharing options...
MrFish Posted October 11, 2009 Author Share Posted October 11, 2009 Ok thanks, but .ajaxStart is a predefined jquery method, right? Link to comment Share on other sites More sharing options...
chibineku Posted October 11, 2009 Share Posted October 11, 2009 It sure is, yeah. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.