jQuery点击需要在IE中点击两次以上

时间:2014-01-20 04:44:41

标签: javascript php jquery internet-explorer

这适用于Chrome和Firefox,但不适用于IE,问题是:

var formData = new FormData($('form')[0]);  // included in script

看我的代码:

HTML:

<form enctype="multipart/form-data">
   <input id="img_file" name="file" type="file" accept="image/x-png, image/gif, image/jpeg">
   <a href="#" id="upload" class="selective">Upload</a>
</form>

JS:

  $(document).on('click', '#upload', function(event) {
    event.preventDefault();
    var formData = new FormData($('form')[0]);
    $.ajax({
      type: 'POST',
      url: 'process.php',
      data: formData,
      cache: false,
      contentType: false,
      processData: false,
      success: function(formData){
        alert(formData); 
      }
    });
  });

有什么建议吗?

0 个答案:

没有答案