多个进度条/文件上传

时间:2014-02-11 07:21:52

标签: java jquery

在这段代码中,我没有获得进度条,即使我无法输入addEventListener,因为警报未被打印。请帮助。

var formData = new FormData();  
formData.append('file', file);
$.ajax({
    url: 'submit-file-upload-rc',  //Server script to process data
    type: 'POST',
    xhr: function() {  // Custom XMLHttpRequest     
        var myXhr = $.ajaxSettings.xhr();
        if(myXhr.upload){ // Check if upload property exists            
            myXhr.upload.addEventListener('progress',function (ev) {
                alert("hello");
                if(ev.lengthComputable){                        
                    $('progress').attr({value:e.loaded,max:e.total});                      
                }
            }, false); // For handling the progress of the upload
        }
        return myXhr;
    },
    //Ajax events        
    beforeSend: function (e){},
    success: function (json){ },
    error: function (json) { },
    // Form data
    //data: formData,
    //Options to tell jQuery not to process data or worry about content-type.
    cache: false,
    contentType: false,
    processData: false
});     

0 个答案:

没有答案