在W3school上找到答案:
请始终为按钮规定 type 属性。Internet Explorer 的默认类型是 “button”,而其他浏览器中(包括 W3C 规范)的默认值是 “submit”。
我用的谷歌浏览器,想必默认type为“submit”
解决方法:
<button type="button" onclick="ajaxPost()">提交</button>
加上 type="button"
在W3school上找到答案:
请始终为按钮规定 type 属性。Internet Explorer 的默认类型是 “button”,而其他浏览器中(包括 W3C 规范)的默认值是 “submit”。
我用的谷歌浏览器,想必默认type为“submit”
解决方法:
<button type="button" onclick="ajaxPost()">提交</button>
加上 type="button"