jqXHR对象

    //$.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]);
    });
});

 

posted @ 2017-02-13 14:42  党兴明  阅读(2344)  评论(0编辑  收藏  举报