日期:2014-05-16  浏览次数:20690 次

ajaxSubmit做文件上传为什么在IE中进度条无反应?急!
最近做的一个项目要文件上传,我子啊火狐中测试一切正常,在谷歌浏览器也正常,怎么到了IE那进度条就不走了呢?研究发现是IE中uploadProgress没有执行,具体代码如下
 
  var options = {	
    beforeSend: function() {
       progress.show();
        var percentVal = '0%';
        bar.css('width',percentVal)
        percent.html(percentVal);
        status.html('上传中……')
    },
    uploadProgress: function(event, position, total, percentComplete) {
                alert('怎么就IE不执行这里呢?郁闷')
        var percentVal = percentComplete + '%';
        bar.width(percentVal)
        percent.html(percentVal);
//console.log(percentVal, position, total);
    },
dataType:'json',
error:function(data){
 status.html("上传失败");
                bar.width('0')
                     },
success: function(data) {
status.html('上传成功')
bar.width('100%')
            } };
     // 将options传给ajaxSubmit
    $('#formbook').ajaxSubmit(options);

这里beforeSend、dataType、error、success都是有效的,怎么就uploadProgress不会执行呢?仔细去jquery.form.js里研究了一天源码,也没有个结果,请各位高手指教,非常感谢了!!!
    (以下可疑不看)
     在源码里发现一个问题,不知道IE为什么会进这里:也就是为什么执行这里if里面
     这面是这段可疑的源码:

var s = $.extend(true, {}, $.ajaxSettings, options, {
        contentType: false,
        processData: false,
        cache: false,
        type: method || 'POST'
    });
    [color=#FF0000]if (options.iframe !== false && (options.iframe || shouldUseFrame)) {
        // hack to fix Safari hang (thanks to Tim Molendijk for this)
        // see:  http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
        if (options.closeKeepAlive) {
            $.get(options.closeKeepAlive, function() {
                jqxhr = fileUploadIframe(a);
            });
        }
        else {
         //IE执行这里