<small id='eGmfA'></small><noframes id='eGmfA'>

    1. <i id='eGmfA'><tr id='eGmfA'><dt id='eGmfA'><q id='eGmfA'><span id='eGmfA'><b id='eGmfA'><form id='eGmfA'><ins id='eGmfA'></ins><ul id='eGmfA'></ul><sub id='eGmfA'></sub></form><legend id='eGmfA'></legend><bdo id='eGmfA'><pre id='eGmfA'><center id='eGmfA'></center></pre></bdo></b><th id='eGmfA'></th></span></q></dt></tr></i><div id='eGmfA'><tfoot id='eGmfA'></tfoot><dl id='eGmfA'><fieldset id='eGmfA'></fieldset></dl></div>
      • <bdo id='eGmfA'></bdo><ul id='eGmfA'></ul>

      <legend id='eGmfA'><style id='eGmfA'><dir id='eGmfA'><q id='eGmfA'></q></dir></style></legend>
    2. <tfoot id='eGmfA'></tfoot>

        IE8/9 中的表单数据

        时间:2023-10-15
          <bdo id='h88jM'></bdo><ul id='h88jM'></ul>
              <tfoot id='h88jM'></tfoot>

                <small id='h88jM'></small><noframes id='h88jM'>

              1. <i id='h88jM'><tr id='h88jM'><dt id='h88jM'><q id='h88jM'><span id='h88jM'><b id='h88jM'><form id='h88jM'><ins id='h88jM'></ins><ul id='h88jM'></ul><sub id='h88jM'></sub></form><legend id='h88jM'></legend><bdo id='h88jM'><pre id='h88jM'><center id='h88jM'></center></pre></bdo></b><th id='h88jM'></th></span></q></dt></tr></i><div id='h88jM'><tfoot id='h88jM'></tfoot><dl id='h88jM'><fieldset id='h88jM'></fieldset></dl></div>
                  <legend id='h88jM'><style id='h88jM'><dir id='h88jM'><q id='h88jM'></q></dir></style></legend>

                    <tbody id='h88jM'></tbody>
                  本文介绍了IE8/9 中的表单数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我已经实现了这个使用 ajax 上传文件的脚本,它在除资源管理器之外的其他浏览器中完美运行,我注意到 IE9 和更少不支持 formData,在 IE 中有没有 formData 的替代品,我想使用干净javascript

                  i have implemented this script for uploading files with ajax, it works perfect in other browsers except for explorer, i noticed that formData is not supported by IE9 and less, are there any alternatives for formData in IE, and i want use clean javascript

                      function doObjUploadExplorer(url, lnk_id, file, progress, success, content, frm, div_dlg, start_func){
                      var file_input = null,
                        frm_data = new FormData(),
                        req;
                  
                      try {
                          //firefox, chrome, safari etc
                          req = new XMLHttpRequest();
                      }
                  
                      catch (e) {
                          // Internet Explorer Browsers
                          req = new ActiveXObject("Microsoft.XMLHTTP");
                      }
                  
                  
                  if (document.getElementById(file)) {
                      file_input = document.getElementById(file);
                  
                      for (var i = 0; i < file_input.files.length; ++i) {
                          frm_data.append(file, file_input.files[i]);
                      }
                  }
                  
                  req.upload.addEventListener('progress', function(e) {  //Event called while upload is in progress
                      if (progress !== undefined
                              && e.lengthComputable) {
                          $('#' + progress).html('<font>Uploading... ' + Math.round((e.loaded / e.total) * 100) + '%</font>');
                      }
                  });
                  
                  req.upload.addEventListener('load', function(e) {  //Event called when upload is completed
                      $('#' + progress).html('<font>Retrieving updated data...</font>');
                  });
                  
                  req.upload.addEventListener('error', function(e) {  //Event called when an error is returned by the server
                      alert('An error has occurred...');
                  });
                  
                  req.addEventListener('readystatechange', function(e) {        
                      if (this.readyState === 4) {
                          if (this.status === 200) {
                              if (content !== undefined) {
                                  $('#' + content).html(this.response);
                              }
                  
                              if (success !== undefined) {
                                  showChkMark(success);
                              }
                          } else {
                              console.log('Server replied with HTTP status: ' + this.status);
                          }
                  
                  
                          if (progress !== undefined) {
                              $('#' + progress).hide();
                          }
                  
                          if (div_dlg !== undefined) {
                              $('#' + div_dlg).dialog('close');
                          }
                  
                          $('#' + file)
                          .attr('disabled', false)
                          .val('');
                      }
                  });
                  
                  if (progress !== undefined) {
                      $('#' + progress).show();
                  }
                  
                  $('#' + file).attr('disabled', true);
                  url += (
                          url.indexOf('?') === -1
                          ? '?'
                          : '&'
                      );
                  url += 'lnk_id=' + lnk_id + '&file=' + file;
                  req.open('POST', url);
                  req.setRequestHeader('Cache-Control', 'no-cache');
                  
                  if (start_func !== undefined) {
                      start_func.apply();
                      setTimeout(function() {
                          req.send(frm_data);
                      }, 500);
                  } else {
                      req.send(frm_data);
                  }}
                  

                  推荐答案

                  IE 中的 FormData 仅支持 IE10,经过研究(我认为)最好的解决方案是使用 ajaxForm:http://malsup.com/jquery/form/ 在 IE8/9 中完美运行,不确定 IE7

                  FormData in IE is only supported from IE10, after doing some research the best solution for this (my opinion) would be using ajaxForm: http://malsup.com/jquery/form/ works perfect in IE8/9, not sure about IE7

                  这篇关于IE8/9 中的表单数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:SCRIPT5:在 IE9 中对 xmlhttprequest 的访问被拒绝 下一篇:获取 API 与 XMLHttpRequest

                  相关文章

                  最新文章

                  <tfoot id='pk6I0'></tfoot>
                      <bdo id='pk6I0'></bdo><ul id='pk6I0'></ul>

                      <small id='pk6I0'></small><noframes id='pk6I0'>

                      <i id='pk6I0'><tr id='pk6I0'><dt id='pk6I0'><q id='pk6I0'><span id='pk6I0'><b id='pk6I0'><form id='pk6I0'><ins id='pk6I0'></ins><ul id='pk6I0'></ul><sub id='pk6I0'></sub></form><legend id='pk6I0'></legend><bdo id='pk6I0'><pre id='pk6I0'><center id='pk6I0'></center></pre></bdo></b><th id='pk6I0'></th></span></q></dt></tr></i><div id='pk6I0'><tfoot id='pk6I0'></tfoot><dl id='pk6I0'><fieldset id='pk6I0'></fieldset></dl></div>
                    1. <legend id='pk6I0'><style id='pk6I0'><dir id='pk6I0'><q id='pk6I0'></q></dir></style></legend>