Installing async: false with jQuery?

Is there a difference between setting:

$.ajax({
    type: "POST",
    traditional: true,
    url: '/adminTask/doAction',
    async: false, <<<<<<<<<<<<<<  HERE
    data: parms,
    dataType: "json",
    success: function (data) {
        $("#rdy_msg").text("Completed: " + id);
    },
    error: function () {
        var cdefg = data;
    }
});

and

$.ajaxSetup({
   async: false
});

The reason I'm asking is because I recently posted a question, and one person mentioned for me to use ajaxSetup and set async: false. However, I thought it was already installed in the code above.

+5
source share
5 answers

The difference is that usage ajaxSetupwill affect all AJAX calls unless you redefine it in the specific settings for that call.

When you set a property asyncin certain settings for this call, it will not depend on the parameter ajaxSetup.

+3
source

, . ajaxSetup, , - .

0

ajaxSetup ajax. , AJAX.

$.ajaxSetup:

Ajax

0

, $.ajaxSetup ajax, , , , .

http://api.jquery.com/jQuery.ajaxSetup/

0

All Articles