I'm learning asp.net mvc by working on a test project including SubSonic and jQuery.
The problem that I'm encountering is that every time I want to return something more than a simple string, like a Json object, I get stymied because callbacks don't seem to fire, or come back as failed.
My method to get a list of jobs 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've played around with get, post and getJSON using both inline and outside function definitions for success and failure. Nothing seems to work, but the code is definitely making the Ajax call, just not firing the callback.