Home > Web Front-end > JS Tutorial > body text

Solution to form that only submits data without page jump_jquery

WBOY
Release: 2016-05-16 17:22:08
Original
1758 people have browsed it

The general form submission operation is written as

Copy the code The code is as follows:


......



Click the submit button or press Enter directly to submit the data to the saveReport page, but it will also jump to the saveReport page after submission

How to do it
Submit the data to saveReport (action of the form Points to) page, but the page does not jump, that is, the current page remains unchanged? ?
This need is especially urgent when loading a page.

Use jquery's ajaxSubmit function and form's onsubmit function to complete, as follows:
Copy code The code is as follows:






Form adds an id for calling in jquery, and adds an onsubmit function for submitting before submitting. The corresponding function of form

saveReport is
Copy the code The code is as follows:

function saveReport() {
// jquery form submission
$("#showDataForm").ajaxSubmit(function(message) {
// For processing after successful form submission, message is the submission page saveReport.htm Return content
});

return false; // False must be returned, otherwise the form will submit again and the page will jump
}
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template