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

Submitting a form without refreshing without using ajax_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:25:181035browse

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^_^

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