2012-11-15 63 views
0
提交

我用jquery.fileupload.js和jQuery 1.7.2對象不支持屬性或方法在IE9

<input class="file_upload_start" type="file" name="files[]" original-title="" multiple="multiple"> 

我file.js http://www.kcloud.vn/apps/files/js/files.js

$(function() { 

    $('.file_upload_start').fileupload({ 

     dropZone:$('#content'), // restrict dropZone to content div 
     add:function (e, data) { 
      var files = data.files; 
      var totalSize = 0; 


data.submit().success(function (data, status) { 
            response = jQuery.parseJSON(data[0].body.innerText); 
            if (response[0] != undefined && response[0].status == 'success') { 
             var file = response[0]; 
             delete uploadingFiles[file.name]; 
             $('tr').filterAttr('data-file', file.name).data('mime', file.mime); 
             var size = $('tr').filterAttr('data-file', file.name).find('td.filesize').text(); 
             if (size == t('files', 'Pending')) { 
              $('tr').filterAttr('data-file', file.name).find('td.filesize').text(file.size); 
             } 
             FileList.loadingDone(file.name); 
            } 

當運行有錯誤SCRIPT438: Object doesn't support property or method 'submit' files.js, line 387 character 37

如何解決? 感謝您的提前!

+4

數據定義在哪裏?之後的東西並不重要。 –

+0

$(函數(){ $( 'file_upload_start。 ')文件上傳({ 懸浮窗:$(' #內容'),//限制懸浮窗到內容的div 增加:功能(即,數據){ var files = data.files; var totalSize = 0; – giaosudau

+0

http://www.kcloud.vn/apps/files/js/files.js – giaosudau

回答

2

下面是從http://www.kcloud.vn/apps/files/js/files.js直到387行的摘錄。代碼註釋包含解釋。

$(function() { 
    $('.file_upload_start').fileupload({ 
     dropZone: $('#content'), // restrict dropZone to content div 
     add: function (e, data) { 
      //data.submit() should definitely exist in this scope. 
      //...stuff... 
      $.ajax({ 
       url: '/?app=files&getfile=ajax%2Fupload.php', 
       dataType: "json", 
       success: function (data) { 
        //which "data" is scoped here? "add" (parent) or "success" (local)? 
        //IE is picking local scope, not parent, which is causing your error. 
        //Rename the parameter variable to something else. 
        if (data.data.message == "DAT") { 
         //...stuff... 
        } else { 
         if (files) { 
          //...stuff... 
         } 
         if (totalSize > $('#max_upload').val()) { 
          //...stuff... 
         } else { 
          if ($.support.xhrFileUpload) { 
           //...stuff... 
          } else { //"data" below in "success" scope does not have a "submit" method, hence your error. 
           data.submit().success(function (data, status) { // <-- Line 387 
            //Yet another parameter variable named "data". 
            //This is asking for more trouble, rename this one too, 
            //or define your functions elsewhere and reference them here. 
            //...stuff... 
           }); 
          } 
//...stuff... 
相關問題