-->

ajaxSubmit and Internet explorer issue

2019-07-08 16:50发布

问题:

I'm stuck for quite some time with this, could someone help me out ? Everything is working fine with Chrome and FF, but for some reason the form won't submit with IE7/IE8/IE9.

function addFile()
{
if ( test > 30 ) { console.log( "addFile" ) ; }

var optionsAjaxFormFile = { 
    url : 'js/fileUpload.php',
    success : showResponseFile
}; 

console.log("about to submit Ajax");
$("#addFile-form").ajaxSubmit( optionsAjaxFormFile );   
}

I know from the Console it goes to the ajaxSubmit line, but it never starts the showResponseFile function. Why ???

Cheers

回答1:

Not sure but you can try with this:

$(document).ready(function() { 
   $("#addFile-form").submit(function(){
      $(this).ajaxSubmit(optionsAjaxFormFile);
      return false; 
   });
});


回答2:

console is only defined in IE9 when its DOM inspector is open, replace console.log() with

if(typeof(console)!='undefined'){
 console.log("about to submit Ajax");
}

or you can use the good old alert



回答3:

In between the head tag add

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" >

you will also need to close and open IE again for the meta tag to work