Home > Web Front-end > JS Tutorial > Submitting a form without refreshing without using ajax_javascript skills

Submitting a form without refreshing without using ajax_javascript skills

WBOY
Release: 2016-05-16 16:25:18
Original
1054 people have browsed it

HTML code:

Copy code The code is as follows:



Here is the form content

JS code:

If the saving is successful, the background returns {"ok":true}; if the saving fails, the background returns {"ok":false, "msg":"error message"}

Copy code The code is as follows:

function save() {
$("#frm").submit();
$("#fra").one("load", function () {
          var data = eval("(" $("#fra").contents().find("body").html() ")");
If (data.ok) {
$("#divtrackroad").load("TrackRoad?roadId=" '@ViewBag.roadId' "&roadName=" '@ViewBag.roadName' "&viewOrEdit=1&t=" new Date().valueOf());
         } else {
alert("Save failed: " data.msg);
}
});
}

Isn’t it very simple? If you friends need it, just take it away, you’re welcome^_^

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