Jeff Jeff - 10 days ago 5
jQuery Question

Async false for shorthand AJAX get request

I am using the following ajax get function to check the status of a user. Is it possible to set

async: false
with this shorthand method? If not how can this be changed so that I can add async false?

$.get("/submit/checkuser/", function (userStatus) {
if (userStatus == 'Disabled') { // check if user if disabled

} else if (userStatus == 'Deleted') { // check if user if deleted

} else {

};
}).fail(function () {
connectionError();
});

Answer

This might work for you

$.ajax({
    url : "/submit/checkuser/",
    type : "get",
    async: false,
    success : function(userStatus) {
       if (userStatus == 'Disabled') { // check if user if disabled                    
       } else if (userStatus == 'Deleted') { // check if user if deleted
       } else {
       };
    },
    error: function() {
       connectionError();
    }
 });