Ajax will automatically refresh the page after passing parameters

Found the answer on W3school:
Please always specify the type attribute for the button. The default type of Internet Explorer is "button", and the default value in other browsers (including W3C specifications) is "submit".
I use Google Chrome, presumably the default type is "submit"

Solution:

<button  type="button" onclick="ajaxPost()">提交</button>

Add type="button" 

Guess you like

Origin blog.csdn.net/qq_43737121/article/details/105719106