我已經建立了的getJSON呼叫時在我的.NET MVC應用程序頁面加載這樣的:的jQuery的getJSON與.NET MVC不工作
$(document).ready(function(){
$.getJSON("/Administrator/GetAllUsers", function (res) {
// getting internal server error here...
});
});
和動作看起來是這樣的:
[HttpGet]
[ActionName("GetAllUsers")]
public string GetAllUsers()
{
return new JavaScriptSerializer().Serialize(ctx.zsp_select_allusers().ToList());
}
我得到這個錯誤:
500 (Internal Server Error)
我在做什麼錯在這裏???
'return Json(ctx.zsp_select_allusers(),JsonRequestBehavior.AllowGet);' –
在Administrator/GetAllUsers之前刪除斜線並檢查。你的返回類型應該是JsonReturn –
它的需要是public ActionResult GetAllUsers()或public JsonResult GetAllUsers() –