epitka
epitka

Reputation: 17655

jQuery: detect ajax call

Is there a way to detect when one of the plugins successfully completes ajax call using $.ajax. I am using a treeview plugin that calls asp.net webservice, and I want to attach context menu to the branches/leafs once they've been loaded.

Upvotes: 1

Views: 2052

Answers (2)

Sampson
Sampson

Reputation: 268492

Have you looked into $.ajaxComplete();, $.ajaxSuccess();, or the callback functions within the requests themselves:

$.post("somepage.php", {var:"val"}, function(results) {
  /* this is the callback, which happens after the response is received */
  alert(results);
});

Take a look at the other Global Ajax Event Handlers.

Upvotes: 2

kioleanu
kioleanu

Reputation: 947

Use the "success" function

$.ajax({
      type: "POST",
      url: "some.php",
      data: "name=John&location=Boston",
      success: function(msg){
        //the action to be done when the call is complete
      }
   });

Upvotes: 0

Related Questions