Stop $.ajax on beforeSend

后端 未结 4 709
南笙
南笙 2020-12-01 04:59

I have this jQuery ajax call:

$.ajax({
    url : \'my_action\',
    dataType: \'script\',
    beforeSend : function(){
        if(1 == 1) //just an example
          


        
4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-01 05:39

    xhr.done(); this works for me

    $.ajax({
        url : 'my_action',
        dataType: 'script',
        beforeSend : function(xhr){
            if(1 == 1) //just an example
            {
                return false
            };
            xhr.done(); //this works for me
        },
        complete: function(){
            console.log('DONE');
        }
    });
    

    http://api.jquery.com/jquery.ajax/

    jqXHR.done(function( data, textStatus, jqXHR ) {});
    

    An alternative construct to the success callback option, refer to deferred.done() for implementation details.

提交回复
热议问题