Solution for objects that do not support the “preventDefault” property or method
When doing Ajax form submission, you need to block the browser's default action, if it is Google or Firefox and other nowadays browsers, directly use theevent.preventDefault();Sadly, this method doesn't work under Internet Explorer, not even IE10. IE actually has its own way of blocking default behavior.window.event.returnValue = false;But this method of modern browsers do not recognize, to be compatible with different browsers, we have to make a judgment, different browsers with the appropriate support to block the default behavior of the method is good. Code is as follows:
if(document.all){ // judge IE browser
window.event.returnValue = false;
}
else{
event.preventDefault();
}; };
Just add this code to the top of the Submit Ajax Form function.
Or, we could rewrite itpreventDefaultfunction, which writes the code for compatibility with each browser into this function:
function preventDefault(event){ if(document.all){ if(document.all){ window.event.returnValue = false; window.event. }else{ event.preventDefault(); } }
Add the above function to the js file, and when referencing it elsewhere, you don't have to judge the browser anymore, you can just use thepreventDefault().;That's all.
Thanks, solved my problem.
Haha, you're welcome, it works.