HTML code:
The code copy is as follows:
<iframe id="fra" name="frm" style="display: none;"></iframe>
<form id="frm" method="post" action="@Url.Content("~/Backstage/MachineMng/RoadSet/SaveTrackRoad")[email protected]" target="frm">
Here is the form content
</form>
JS code:
If the save is successful, the background returns {"ok":true}; if the save is failed, the background returns {"ok":false, "msg":"Error message"}
The code copy 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 need it, take it away directly, don't be polite^_^