如何在jQuery中使用queue()

I have the following jQuery code that submits a form (via an AJAX function):

$("#btnUpdate").on( "click",function(event){
    //disable default click operation
    event.preventDefault();
    update_conference_settings();
    $('.welcome-lightbox-close').click();
  });

update_conference_settings() is the function that submits an ajax form and returns a confirmation. .welcome-lightbox-close closes the modal that the form sits in.

At the moment, .welcome-lightbox-close appears to close immediately, without update_conference_settings returning a confirmation (although the form does submit). How can I add a queue to this?

http://api.jquery.com/queue/ would appear to be the right function, but I'm not sure how the syntax would work on update_conference_settings(); code?

Thanks

From your update_conference_settings() function return the return value of $.ajax(). And then update your code as

$("#btnUpdate").on( "click",function(event){
    //disable default click operation
    event.preventDefault();
    update_conference_settings().then(function() {
            $('.welcome-lightbox-close').click();
        });
});

Here we are using the deferred object returned by $.ajax().