JS Implementation form submission does not refresh the current page _javascript tips

Source: Internet
Author: User

How to implement a form submission without refreshing the current page

<form name= ' Form1 ' id= ' Form1 ' action= ' '/xbcw/cw/xx_xx.action ' method= ' post ' > <input type= '
button ' id= ' Btnsubmit "Name=" btnsubmit "value=" Save "onclick=" ADDKP () "class=" "Button2"/> <input type=
"button" id= " Btnsubmit "Name=" btnsubmit "value=" Next "onclick=" Doaddcwkpsubmit () "class=" Button2 "/>
</form>

When I click the Save Submit Form form, how do I keep the current page unchanged (that is, not refresh the current page)?

Add an iframe after the form form

  <iframe id="rfFrame" name="rfFrame" src="about:blank" style="display:none;"></iframe>

Point Save Commit event you need to change target to an IFRAME name:

  JS:document.forms[0].target="rfFrame";

JQuery:$("#f2").attr("target","rfFrame");

This means that the form is submitted to save the data, and the page will not jump.

The above is the entire content of this article, I hope to help you, but also hope that a lot of support cloud Habitat community!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.