Search code examples
ajaxjqueryjquery-validatejquery-post

Running two .ajax()


As title, I have two ajax() has to go through but in condition that A ajax has to be go through in order to do B ajax.

A ajax as in <<=== .ajaxFileupload()

B ajax as in <<=== .ajax()

Any recommend to do the condition so that A must be success in order to do B ?? or any method that I shall implement ?

To alex:

u mean something like this ??

$.ajaxFileUpload({
   .....
   .....
   success:function(data){
           $.ajax({


           });

   }

});

Solution

  • Call B inside of the success handler for A..

    $.ajaxA({
      url: "test.html",
      context: document.body,
      success: function(){
          $.ajaxB....
      }
    });
    

    jQuery Ajax API docs for more info on the success method.