After the js form is submitted, the current page is not refreshed again. After the js form is submitted, the current

Source: Internet
Author: User

After the js form is submitted, the current page is not refreshed again. After the js form is submitted, the current

How to Implement form submission without refresh 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>

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

Add an iframe after the FORM

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

Click Save submit event to change target to the iframe Name:

JS: document.forms%0%.tar get = "rfFrame ";

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

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

The above is all the content in this article. I hope it will be helpful to you, and I also hope to provide more support for the customer's home!

Related Article

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.