No need to submit a new form (non-Ajax implementation), form ajax
HTML code:
<Iframe id = "fra" name = "frm" style = "display: none; "> </iframe> <form id =" frm "method =" post "action =" @ Url. content ("~ /Backstage/MachineMng/RoadSet/SaveTrackRoad ")? RoadId = @ ViewBag. roadId "target =" frm "> here is the form content </form> View Code
JS Code:
If the storage is successful, {"OK": true} is returned in the background. If the storage fails, {"OK": false, "msg": "error message"} is returned in the background "}
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 ("failed to save:" + data. msg) ;}}) ;}view Code