$('#sizeAddHolder').load( '/MyController/MyAction', function () { ... });
我的控制器中的操作代码如下:
public ActionResult MyAction(byte id) { var model = new MyModel { ObjectProp1 = "Some text" }; return View(model); } [HttpPost] public ActionResult MyAction(byte id, FormCollection form) { // TODO: DB insert logic goes here var result = ...; return Json(result); }
* "xml": Returns a XML document that can be processed via jQuery. * "html": Returns HTML as plain text; included script tags are evaluated when inserted in the DOM. * "script": Evaluates the response as JavaScript and returns it as plain text. Disables caching unless option "cache" is used. Note: This will turn POSTs into GETs for remote-domain requests. * "json": Evaluates the response as JSON and returns a JavaScript object. In jQuery 1.4 the JSON data is parsed in a strict manner; any malformed JSON is rejected and a parse error is thrown. (See json.org for more information on proper JSON formatting.) * "jsonp": Loads in a JSON block using JSONP. Will add an extra "?callback=?" to the end of your URL to specify the callback. * "text": A plain text string.
对不起,但我不是如何发布链接HTML。 所以你可以有一个链接class =“delete”, id = value和一个href =“javascript:;”
然后我用这个函数渲染局部视图:
$(".delete").click(function(event){ var id = $(".select").attr("id"); var id2 = event.target.id; $.ajax({ url: "Persona/Delete?idPersona=" + id2.toString(), success: function (data) { $("#popUpConfirmar").html(data); } }); dialogoPopUp.dialog("open"); });
请记住,在控制器中,您必须执行以下操作:
public PartialViewResult Delete(int idPersona) { PersonaDataAccess personaDataAccess = new PersonaDataAccess(); Persona persona = personaDataAccess.GetOne(idPersona); return PartialView("Delete",persona); }