2

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.

2 Answers 2

4

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:

WorkerPool API

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.

Sign up to request clarification or add additional context in comments.

Comments

3

Most modern browsers implement JavaScript Web Workers, they provide a simple way to run scripts in background threads.

Check the following articles:

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.