jsp 页面中使用 $(“form”).submit();进行表单提交,发现怎么都提交不了,
检查form anction 发现没有问题,
手动提交也没有问题。
<dd>
<input type="button" value="立即登录" id="submit" class="submit_btn" />
</dd>
各种百度,排查终于jQuery api发现原因:
于是上jQuery API查找原因,看到以下这段文字顿时明白了:
Additional Notes:
Forms and their child elements should not use input names or ids that conflict with properties of a form, such as submit, length, or method. Name conflicts can cause confusing failures. For a complete list of rules and to check your markup for these problems, see DOMLint.
大概意思是表单和其子元素不宜用一个表单的属性的属性作为name或id的名称,如submit, length, 和 method等,否则会产生冲突,名称冲突可能就会导致这种情况。
原来是因为按钮id设为了submit
接下来只要将id改了就没问题了,
也警示了我们id name等不能命名系统关键字。
<dd>
<input type="button" value="立即登录" class="submit_btn" />
</dd>
感谢