为什么发送ajax请求页面也会刷新呢?

button 标签请添加 type='button' 属性,因为浏览器默认会认为 button 的属性是submit.type=‘submit’时会发生提交表单的默认行为。

<button type='button' class="send_msg" onclick="setData()">send</button>
请始终为按钮规定 type 属性。Internet Explorer 的默认类型是 "button",而其他浏览器中默认值是 "submit"。

猜你喜欢

转载自blog.csdn.net/lxlpokie/article/details/80613811
今日推荐