I had a problem getting a controller method that returns a JsonResult to accept parameters passed using the JQuery getJSON method.
Im code works, it works fine when the second parameter ("data") of the getJSON method method is zero. But when I try to pass the value there, it seems that the controller method is not even called.
In this example, I just want to use an integer. A getJSON call that works fine looks like this:
$.getJSON("/News/ListNewsJson/", null, ListNews_OnReturn);
The controller method is as follows:
public JsonResult ListNewsJson(int? id)
{
…
return Json(toReturn);
}
Having set a breakpoint in the ListNewsJson method, I see that this method is called when the getJSON data parameter is null, but when I replace it with a value, for example, 3:
$.getJSON("/News/ListNewsJson/", 3, ListNews_OnReturn);
... / . , ?
, , ( "/News/ListNewsJson/3" ).