[HttpGet()] public JsonResult AjaxGet(string arg){ Models.BookService service = new Models.BookService(); returnthis.Json(service.GetBookByCondition(), JsonRequestBehavior.AllowGet); }
AJAX Post
在 Controller 裡可以這樣寫
1 2 3 4 5 6 7 8 9
[HttpPost()] public JsonResult AjaxPost(Models.AjaxPostArg arg) { List<SelectListItem> result = new List<SelectListItem>(); result.Add(new SelectListItem() {Value = "1", Text="Admin"}); result.Add(new SelectListItem() {Value = "2", Text="Test"});