Home  >  Article  >  Web Front-end  >  js implements not re-refreshing the current page after form submission

js implements not re-refreshing the current page after form submission

高洛峰
高洛峰Original
2016-12-03 14:03:441581browse

How to prevent the current page from being refreshed after submitting the form

<form name=&#39;form1&#39; id=&#39;form1&#39; action=&#39;/xbcw/cw/xx_xx.action&#39; method=&#39;post&#39;>
  <input type="button" id="btnSubmit" name="btnSubmit" value="保存" onclick="addKp()" class="Button2" />
  <input type="button" id="btnSubmit" name="btnSubmit" value="下一步" onclick="doAddCwKpSubmit()" class="Button2" />
</form>

When I click Save to submit the FORM form, how can I keep the current page unchanged (that is, not refresh the current page)?

Add an iframe after the FORM form

 3fd24ed8386b437cbda9015eab5173f2065276f04003e4622c4fe6b64f465b88

Click Save In the submission event, you need to change the target to the name of the iframe: JS: document.forms[0].target="rfFrame"; );

In this way, the FORM is submitted and the data is saved, and the page will not jump.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn