0

我正在处理验证表单,我正在使用 JS 从 html 字段发送数据,使用 php 文档提取验证并通过 AJAX 将其发送回来,它在 Chrome 中运行良好但在 Internet Explorer 中运行良好(我正在测试它在 IE9 中):

function Checkfiles() {
  var fup = document.getElementById('flUpload');
  var fileName = fup.value;
  var ext = fileName.substring(fileName.lastIndexOf('.') + 1);
  var chkext = ext.toLowerCase();
  if(chkext=="gif" || chkext=="jpg" || chkext=="jpeg" || chkext=="png") { return true; } else { return false; }
} // Checkfiles

function Checksize() { 
var iSize;
if ($("#flUpload")[0].files[0]){ iSize = ($("#flUpload")[0].files[0].size / 1024);}
if(Checkfiles()==true && iSize <= 51.200) { return true; } else { return false; }
} //Checksize

$(document).ready(function() {

   $("#ff1").submit(function(e){
   // prevent submit
   e.preventDefault();

   var email = document.getElementById("email").value;
   var title = document.getElementById("title").value;
   var url = document.getElementById("url").value;

   var parametros = {"emaail":email, "tiitle":title, "uurl":url};
   $.ajax({
    data: parametros,
    url: 'validate.php',
    type: 'post',
    context: this,
    error: function (response) {
        alert("An error has occurred! Try Again!");
    },
    success: function (response) {
        if($.trim(response)=='b' && Checksize()==true) { 
            this.submit(); // submit, bypassing jquery bound event
        } 
        else {
            if (Checksize()==true) {
                $("#ajax_call_val").html('<div id="validation"><ul>'+response+'</ul></div>');
            } else {
                if(response!='b') {
                $("#ajax_call_val").html('<div id="validation"><ul>'+response+'<li>Only GIF, PNG, JPG images, smaller than 50 KB</li></ul></div>');
                } else { $("#ajax_call_val").html('<div id="validation"><ul><li>Only GIF, PNG, JPG images, smaller than 50 KB</li></ul></div>'); }
            }
        }
    }
});

   });

});

任何奇怪为什么不在 IE 中工作?提前致谢。

4

0 回答 0