将其他参数传递给jQuery的$ .ajax()xhr回调

时间:2016-06-10 20:41:52

标签: javascript jquery ajax

我这样做并且效果非常好

$.ajax({
    url : 'php/upload.php',
    xhr: function(){
        var xhr = new XMLHttpRequest();
        xhr.upload.addEventListener("progress", function (e) {
            $('#upload-progress-bar-1').animate({        
                'width': (Math.round(e.loaded / e.total) * 100) + '%'}, 400);
            }, false);
            return xhr;    
        },
        data : this.formData,
        type : 'POST',
        processData: false,
        contentType: false,
        dataType: "json",
        success : function(data) {
            //$('#upload-progress-bar-1').css('width', '100%');
        }
    });

问题是$('#upload-progress-bar-1')是动态的,但我无法弄清楚如何将参数传递给xhr:回调函数。

任何人都知道这样做的方法吗?

1 个答案:

答案 0 :(得分:0)

使用局部变量,并在回调中引用它。

let $_ := xdmp:node-delete(fn:doc($uri)/enevelope:document-enevelope/enevelope:extractedText)
相关问题