//$.ajax()返回的對象就是jqXHR對象 var jqXHR = $.ajax({ type:'post', url:'test.php', data:$('form').serialize() }); //success這個方法可能會取消 jqXHR.success(function(response){ alert(response); }); //相比以前的可以連綴操作,可以多次執行 jqXHR.done(function(response){ alert(response + 'a'); }); jqXHR.done(function(response){ alert(response + 'b'); });


$(function(){ //多個操作指定回調函數 var jqXHR = $.ajax('test.php'); var jqXHR2 = $.ajax('test2.php'); $.when(jqXHR,jqXHR2).done(function(r1,r2){ alert(r1[0]); alert(r2[0]); }); });
