Search Results

Search found 1 results on 1 pages for 'moskie'.

Page 1/1 | 1 

  • ASP.Net MVC Json Result: Parameters passed to controller method issue

    - by Moskie
    I'm having a problem getting a controller method that returns a JsonResult to accept parameters passed via the JQuery getJSON method. The code I’m working on works fine when the second parameter ("data") of the getJSON method call is null. But when I attempt to pass in a value there, it seems as if the controller method never even gets called. In this example case, I just want to use an integer. The getJSON call that works fine looks like this: $.getJSON(”/News/ListNewsJson/”, null, ListNews_OnReturn); The controller method is like this: public JsonResult ListNewsJson(int? id) { … return Json(toReturn); } By putting a breakpoint in the ListNewsJson method, I see that this method gets called when the data parameter of getJSON is null, but when I replace it with value, such as, say, 3: $.getJSON(”/News/ListNewsJson/”, 3, ListNews_OnReturn); … the controller method/breakpoint is never hit. Any idea what I'm doing wrong? I should also mention that the controller method works fine if I manually go to the address via my browser ("/News/ListNewsJson/3").

    Read the article

1