我想下面的代碼可以理解。
首先,用 創建一個ajax表單 - RefreshAjaxList:當前控制器的名稱ajax動作。 - string.empty(可選) - ajax選項。 - 表單ID(可選) - 點擊狀態時,我們將編輯狀態調用服務器來更新狀態。 - 編輯狀態後,我們調用提交按鈕來調用RefreshAjaxList。按鈕是 「顯示:無」 - 在本例中,我有一個控制器:AjaxController用2個操作:
enter code here
public ActionResult UpdateStatus(int contactId, Status contactStatus)
{
ContactRepository repo = new ContactRepository();
repo.UpdateStatus(contactId, contactStatus);
return Json("success:true");
}
[AcceptVerbs(HttpVerbs.Post)]
[ActionName("RefreshAjaxList")]
public ActionResult RefreshContact()
{
ContactRepository repo = new ContactRepository();
IList<Contact> list = repo.List();
return PartialView("AjaxUc/AjaxList", repo.List());
}
變種狀態= {活性:1,不活動的:0}; function editStatus(cell,id,active){ if(active) cell.innerHTML =「Active」+ 「Inactive」; 其他 單元格。innerHTML =「有效」+ 「無效」; }
function updateStatus(radio, id, active) {
if (radio.checked != active) {
if (confirm("Do you want to change the status of the contract?")) {
if (active)
cStatus = status.active;
else
cStatus = status.inactive;
$.ajax({
url: 'Ajax/UpdateStatus',
dataType: "json",
data: { contactId: id, contactStatus: cStatus },
success: function(html) {
jQuery("#divAjaxList").submit();
},
error: function(request, desc, ex) {
alert(desc);
}
});
}
}
}
標識 姓 名字 電話 電子郵件 狀態 | ,);「>
欲瞭解更多信息,請發郵件到[email protected]作進一步討論。
希望這可以幫助你。
你能舉個例子嗎。我不確定如何在提交表單後將json數據傳遞給UC ... – Jason 2009-02-04 16:05:39