I\'m attempting to get this working properly (2 days now). I\'m working on a log in where I\'m calling the controller action from jQuery, passing it a JSON object (utilizing
If you're using MVC 2, you have to return something like this :
return Json(your_object, JsonRequestBehavior.AllowGet);
I've found it here
For a different usage, here is my code.
JQuery :
$(document).ready(function () {
$("#InputDate").live('click', function () {
var date = $("#InputDate").val();
if (date != "") {
$.getJSON("/Home/GetNames",
{ date: $("#InputDate").val() },
function (data) {
$("#ProviderName").empty();
// [...]
});
});
}
});
});
And C#
public JsonResult GetNames(string date)
{
List list = new List();
// [...]
return Json(list, JsonRequestBehavior.AllowGet);
}