我在控制器中有以下ActionResult。它返回一个排取决于ID从Ajax显示json数据并在MVC3中显示JQuery对话框查看
[HttpPost]
public ActionResult Get(Guid Id)
{
Ref imp = ReadRepository.GetById(refImpId);
var ijson = new JsonResult() { Data = imp.ToJson() };
return ijson;
}
数据(如身份证,姓名,所在城市等)从数据库以下是jQuery和Ajax的jQuery的对话框。
$(".ImpList").click(function (e) {
// get the imp id
var refImpId = $(this).next('#impId').val();
var impgeturl = $('#impgeturl').val();
var imptoedit = null;
$.ajax({
type: 'post',
url: impgeturl,
data: '{ "refImpId": "' + refImpId + '" }',
contentType: "application/json; charset=utf-8",
traditional: true,
success: function (data) {
imptoedit = jQuery.parseJSON(data);
$("#editImpDialog").dialog({
width: 350,
height: 220,
modal: true,
draggable: false,
resizable: false,
});
},
error: function (request, status, error) {
alert(e); // TODO: need to discuss ajax error handling and form reset strategy.
}
});
});
$("#cancelEditImpBtn").click(function (e) {
e.preventDefault();
$('#editImpDialog').dialog("close");
});
$("#saveEditImpBtn").click(function (e) {
e.preventDefault();
$("form").submit();
});
我在我的视图中有一个对话框。我需要将Json数据显示到Jquery对话框中。我怎样才能做到这一点?
您没有使用在我们采取行动的参数。你的代码是真的吗? – rcdmk 2012-04-05 20:48:31