私は以下のActionResultをコントローラに持っています。それがIDAjaxからjsonデータを表示し、MVC3でJQueryダイアログに表示する
[HttpPost]
public ActionResult Get(Guid Id)
{
Ref imp = ReadRepository.GetById(refImpId);
var ijson = new JsonResult() { Data = imp.ToJson() };
return ijson;
}
に応じてデータベースから(例えば、ID、名前、都市などのような)データの行に続いてjQueryのダイアログのjQueryとAjaxのあるを返します。
$(".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ダイアログに表示する必要があります。どうやってやるの?
あなたがGETアクションにパラメータを使用していません。あなたのコードは本当にそれですか? – rcdmk