Timeline for How do I return a JSON object from controller in ASP.NET MVC 4?
Current License: CC BY-SA 3.0
10 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Apr 30, 2014 at 19:45 | vote | accept | user3562751 | ||
| Apr 23, 2014 at 5:11 | history | edited | Phil.Wheeler | CC BY-SA 3.0 |
Expanded on original answer.
|
| Apr 23, 2014 at 4:58 | comment | added | user3562751 | Yes that worked! Object {ID: 4244, Name: "Kevin Durant", TeamName: "okc", Position: "F"} | |
| Apr 23, 2014 at 4:53 | comment | added | Phil.Wheeler |
In your $.ajax method, can you try hard-coding the URL and include the ID you're trying to pass as well? So your url should look like url: '/controller/AddToPreRank/1' for example. What do you get as a result?
|
|
| Apr 23, 2014 at 4:43 | comment | added | user3562751 | It is in an <a> element. It is not in a form, it is just a list of players and I want the player to appear in my prerank list when I click add. | |
| Apr 23, 2014 at 4:35 | comment | added | Phil.Wheeler |
What kind of element is .AddToPreRank and is it enclosed in a <form> element? I want to confirm you're not submitting a form at the same time as sending the Ajax request.
|
|
| Apr 23, 2014 at 4:22 | comment | added | user3562751 | Im using chrome. Im not sure where to look for the Controller/Action method being called. The HTML being returned is the page where the button click happened. | |
| Apr 23, 2014 at 4:16 | comment | added | Phil.Wheeler | Are you using [getglimpse.com](Glimpse)? In the browser's debug console, what Controller / Action method do you see being called? What content do you see in the HTML being returned? Is it a regular page or is there odd / error content on there? | |
| Apr 23, 2014 at 4:14 | comment | added | user3562751 | Thanks for the response. I am still getting the same result. I was also curious as to why I cannot run in debug mode to see if the Id is actually passed to the controller. When I set the breakpoint, nothing happens. | |
| Apr 23, 2014 at 3:10 | history | answered | Phil.Wheeler | CC BY-SA 3.0 |