Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AJAX .post async

What exactly does the following do:

$.ajax({
     type: "POST",
     async: false,

vs

$.ajax({
    type: "POST",
    async: true,

Meaning what is the difference in the behavior?

like image 494
Nate Pet Avatar asked May 29 '12 15:05

Nate Pet


People also ask

Is AJAX get async?

It's asynchronous in that it doesn't lock up the browser. If you fire an Ajax request, the user can still work while the request is waiting for a response. When the server returns the response, a callback runs to handle it.

Can we use async await in AJAX?

Since async/await is just Promise's under the hood, I wonder if I can use async/await with jQuery's $. ajax(). Turns out, you can!

Is jQuery AJAX asynchronous?

Definition and Usage. The ajax() method is used to perform an AJAX (asynchronous HTTP) request. All jQuery AJAX methods use the ajax() method. This method is mostly used for requests where the other methods cannot be used.

Is an AJAX call synchronous or asynchronous?

AJAX, which stands for asynchronous JavaScript and XML, is a technique that allows web pages to be updated asynchronously, which means that the browser doesn't need to reload the entire page when only a small bit of data on the page has changed. AJAX passes only the updated information to and from the server.


1 Answers

From the jQuery site:

By default, all requests are sent asynchronously (i.e. this is set to true by default). If you need synchronous requests, set this option to false. Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active.

That's all there is to it. If you need help on a specific problem let me know.

like image 80
woz Avatar answered Oct 11 '22 16:10

woz