livinzlife
livinzlife

Reputation: 873

.load() with animated .gif while waiting for results

I am using jquery .load() method to load results of a search within a div like so (dumbed down version)

$('#resultscontainer').load("results.php", {data: data});

The end result will require more data to be sent and a potential waiting time for the results to be loaded into the div. Is it possible to have an animated gif (like a spinning icon) show within the div "resultscontainer" while it is processing the data?

Upvotes: 2

Views: 2505

Answers (1)

megakorre
megakorre

Reputation: 2223

Sup livinzlife

yea ofc there is special events in jquery for this :D

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

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

where #loading is your gif for example: http://www.ajaxload.info/

Upvotes: 4

Related Questions