I want to return a JSON result. To do this I have a controller method as follows that is called from a Ajax.BeginForm
on the View:
@using (Ajax.BeginForm("Update", new AjaxOptions { OnSuccess = "MySuccessMethod()" }))
{
<!-- some form stuff -->
<input type="submit" value="Submit"/>
}
This is the controller that handles it:
[HttpPost]
public JsonResult Update(FormCollection fc)
{
// Process form stuff
return Json (new {success = true });
}
What I want is to process the success response with MySuccessMethod
. What I see is that the view on submit goes to the correct controller method above, which then redirects the page to the URL /Home/Update
with the following string in the screen:
{"success": true }
Not sure if it is relevant but I am using Mono.
How can I make the framework not switch pages to /Home/Update
nor display the JSON string on the view and just process the JSON in the back?