Reputation: 4383
For example, I would like to download part of data from the server when I click one button, and downloading other parts in background. How to implement this?
Upvotes: 1
Views: 124
Reputation: 5438
If you are targetting HTML5 compatible browsers take a look at Web Workers :
http://www.html5rocks.com/en/tutorials/workers/basics/
Background processes with web workers:
http://www.youtube.com/watch?v=VIdkYaLbzMs
Upvotes: 2
Reputation: 211
You have only one execution thread, so you will have to play with setInterval() and clearInterval() and execute your code based on timers :
var iv= setInterval(function(){ alert("Running now!"); }, 3000);
Clear the periodic function with :
clearInterval(iv);
Upvotes: 0