When submitting Ajax forms, you need to stop the default action of the browser. If it is a current browser such as Google or Firefox, use event.preventDefault () directly; Just fine, sadly, this method will not work under IE browser, even IE10. How to solve it? IE actually has its own method to stop the default behavior window.event.returnValue = false; However, modern browsers don’t recognize this method. To be compatible with different browsers, we have to make a judgment. Different browsers should use corresponding supporting methods to prevent the default behavior. The code is as follows:
If(document.all){ // Judge IE browser.
window.event.returnValue = false;
}
else{
event.preventDefault();
};
Just add this code to the function of submitting Ajax forms.
Or, we can rewrite the preventDefault function and write the code compatible with all browsers into this function:
function preventDefault(event){
if(document.all){
window.event.returnValue = false;
}else{
event.preventDefault();
}
}
Add the above function to the js file, and when it is referenced in other places, you don’t need to judge the browser, just use preventDefault (); Just do it.