0

我有两个具有相同流程的相同表单,调用一个函数,该函数执行 ajax POST 并在<p>标签中打印结果,但是其中一个表单仅在 Firefox 上提交,而它在 Chrome 上按预期工作。另一种形式在两种浏览器上都可以正常工作,但两种形式是相同的。

<form name="myForm" onsubmit="dopostback()">
    <!-- form controls here -->      
    <p id="msg"></p>          
    <button type="submit">Send</button>                                             
</form>

调用的函数是这样的:

function dopostback(){
    if (document.myForm.checkValidity()){
        // here collect relevant data and do a $.ajax POST
        // the result end up in a <p> tag above the submit button
    }

    return false; //IMPORTANT: this prevents the form from being submitted, tested on the other form
}

我能想到的唯一真正的区别是,在两种浏览器上工作的表单都有dopostback()一个.js文件内部(当然,在这两种情况下都是在 jQuery 之后)另一个表单在页面内部有脚本,所以不包括外部.js文件,再次脚本在 jQuery 之后,在 Firefox 上,这个表单在 Chrome 上不是提交的,但两者几乎都在做同样的事情。

4

0 回答 0