5

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?

Ajay2707
  • 5,690
  • 6
  • 40
  • 58
Nate Pet
  • 44,246
  • 124
  • 269
  • 414
  • You can find answer of your question in this link: https://stackoverflow.com/questions/1478295/what-does-async-false-do-in-jquery-ajax – Farhad Misirli May 20 '19 at 14:34

2 Answers2

6

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.

woz
  • 10,888
  • 3
  • 34
  • 64
0

The async call not "break" execution of javascript code. Need callback's function for when return of request from server delivery. It is more complicate to development and need more control of your´s functions.

Jones
  • 1,480
  • 19
  • 34