HTML端js代码 var url='CAR/GetCAR' var JSONStr = String.format('{"BU":"{0}","CARType":"{1}"}',BU,CarType); htmlobj = $.ajax({ url: url,type: "POST",async: false,contentType: "application/json",data: JSONStr,}); $("#divBody").html(htmlobj.responseText);
Control 层中Action [HttpPost] public ActionResult CAROverallTrackingProjectStep(CARModel cm) { ViewBag.param = JsonConvert.SerializeObject(cm); return View(); } [HttpPost] public ActionResult CAROverallTrackingProjectStep_(CARModel cm) { ViewBag.param = JsonConvert.SerializeObject(cm); return PartialView("CAROverallTrackingProjectStep"); } CARModel实体类 using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace CAR.Models{ public class CARModel { private string bu; public string BU { set { bu = value; } get { return bu != null ? bu : ""; } } private string cartype; public string CARType { set { cartype = value; } get { return cartype != null ? cartype : ""; } } } }原文链接:https://www.f2er.com/ajax/160658.html
HTML网页得到参数方法 <input type="text" id="txtParam" value="@ViewBag.Param" style="width:200px" >