Reputation: 4006
We have AJAX calls to hit a URL. Do we have option to run/execute JavaScript function in Asynchronous mode?
Note: setTimeout() will execute that function after some seconds but still that will execute in Synchronous mode.
Upvotes: 2
Views: 672
Reputation: 31522
No. JavaScript runs in a single thread per page.
You want HTML5 Web Workers. There's a good introduction on HTML5 Rocks.
However, the Google Gears plugin provides a WorkerPool
:
The WorkerPool API allows web applications to run JavaScript code in the background, without blocking the main page's script execution.
There's also a proposal by the Gears team to add this to HTML5.
Upvotes: 4
Reputation: 827496
Most modern browsers implement JavaScript Web Workers, they provide a simple way to run scripts in background threads.
Check the following articles:
Upvotes: 3