I spent a LONG time looking into this and just can't see what's wrong. I have the following:
$.getJSON(
'/adminStatus/GetJsonData',
{ name: $('#textSearch')[0].value },
function (data) {
alert("3");
// $('#studentList > div').remove();
// for (s in data) {
// alert("4");
// var student = data[s];
// $('#studentList').append('<div>(' + student.StudentId + ') ' + student.FirstName + ' ' + student.LastName + '</div>');
// }
}
);
This code fires an action in my controller and that action returns data. It's actually code from another example:
public JsonResult GetJsonData(string name)
{
return new JsonResult
{
Data = (from student in Student.GetStudentDataList()
where student.LastName.StartsWith(name)
select student).ToArray<Student>()
};
}
I check and Data is getting populated with data.
However nothing is happening with return data and when I added comments then I cannot even get the alert("3") to appear.
Am I doing something really obviously wrong? I think I'm copying a working example but nothing seems to be returned and the function (data) {} does not seem to execute.
Any help would be much appreciated.
Thanks,