I am learning asp.net mvc while working on a test project including SubSonic and jQuery.
The problem I am facing is that every time I want to return something more than a simple string, such as a Json object, I get muted because callbacks don't seem to work or don't return as a failure .
My method for getting a list of tasks in the database:
[AcceptVerbs(HttpVerbs.Get)] public JsonResult GetAllJobs() { var db = new JamesTestDB(); var jobs = from job in db.Jobs select job; return Json(jobs.ToList()); }
And my javascript to call it:
function updateJobList() { var url = '<%= Url.Action("GetAllJobs", "Home") %>'; $.getJSON(url, null, function(data, status) { alert("Success!"); }); }
I played with get, post and getJSON using both built-in and external function definitions for success and failure. Nothing seems to work, but the code definitely makes an Ajax call, just without starting the callback.
json jquery asp.net-mvc
James
source share