使用jQuery 1.5,您可以使用全新的
$.Deferred功能,正是为此目的而设计的。
// Assign handlers immediately after making the request,// and remember the jqxhr object for this requestvar jqxhr = $.ajax({ url: "example.php" }) .success(function() { alert("success"); }) .error(function() { alert("error"); }) .complete(function() { alert("complete"); });// perform other work here ...// Set another completion function for the request abovejqxhr.complete(function(){ alert("second complete"); });
资源



