Thursday, April 9, 2009

If getJSON in JQuery can not find exact signature method in Controller, it fails silently.... (ASP.NET MVC)

it fails silently....
Microsoft should put a couple of exclaimation marrk for this documentation somewherem, so we can see to save us sometime!!!!!!!!!!!!!!!!!!!!!!!!!

Example:
If you call getJSON in client side:
$.getJSON('/Home/GetList', { id: $("#country").val() },
You have to create an action in controller in following:
public JsonResult GetList(string id)
{
return Json(test.ToList());
}

But if you:
public JsonResult GetList(int id)
{
return Json(test.ToList());
}

You got nothing!!!!!!!!!!!!!!!!

No comments:

Post a Comment