Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery synchronous functions

Is there a way to run a function after another functions completes? For example:

doSomething();
doSomethingElse();

i only want doSomethingElse() to run after doSomething completes. is this possible?

like image 718
ngreenwood6 Avatar asked Nov 21 '09 00:11

ngreenwood6


People also ask

Are jQuery functions synchronous?

By default jQuery is not providing synchronous request, so we have to implicitly define synchronous request using $. ajax().

Is jQuery function asynchronous?

The jQuery Ajax async is handling Asynchronous HTTP requests in the element. It is a procedure to send a request to the server without interruption. It is an Asynchronous method to send HTTP requests without waiting response. It is a function to working on a server without associating more than on request.

Is jQuery post asynchronous?

The jQuery post() method sends asynchronous http POST request to the server to submit the data to the server and get the response.

Is jQuery load asynchronous?

You can use jQuery to support both synchronous and asynchronous code, with the `$.


1 Answers

If your doSomething() function is doing something asynchronously (such as making an Ajax request) then you'll want to make doSomethingElse() the callback for that asynchronous request, rather than having it execute immediately after doSomething() returns.

like image 127
Marc Novakowski Avatar answered Oct 12 '22 12:10

Marc Novakowski