I am using MVC Ajax to do a form submission. What I can't get right is to get the Action on the server to return a partial view to the browser.
The form submission looks like this:
<% using (Ajax.BeginForm("Add", "Example", new AjaxOptions { HttpMethod = FormMethod.Post.ToString(), OnComplete = "widgetAdded" } )) { %>
This hits the server and the action gets executed. The JavaScript method 'widgetAdded' that gets executed after the action completes looks something like this:
function widgetAdded(ajaxContext) {
var response = ajaxContext.get_response().get_object();
alert(response);
}
If I return a Json result in the action like this, it works - the alert shows the data being passed from the server.
return Json("bob");
Now if I change the action to return a PartialView like this, it doesn't work.
return PartialView("Widgets");
I've tried to interrogate the response object in Firebug, but I can't seem to get the actual view html. Any ideas?