0

I'm using jquery's load() to get some content into a div, and I want to run an other function in the "background" until load() finishes. That function should update a custom throbber every 1 second until $("#id").html() == "" where $("#id").html() is set to "" after load() finishes. Is there any way I can do that?

Cœur
  • 37,241
  • 25
  • 195
  • 267
dandu
  • 800
  • 1
  • 8
  • 18

2 Answers2

2

Have you tried doing what you're describing? It should work like this:

var interval = setInterval(function() {
    // update whatever you want
}, 1000);
$('#id').load('mypage.php', function() {
   clearInterval(interval);
});
Paolo Bergantino
  • 480,997
  • 81
  • 517
  • 436
0

Executing that function before executing the jQuery load command should do it, then in the load callback function, set $("#id").html("")

Russ Cam
  • 124,184
  • 33
  • 204
  • 266