I'm handling the submit portion of a ASP.NET MVC 2 page via javascript/JQuery because i need to construct some arrays, in the controller i either return back a View (if there are errors) or a URL (redirect)
I can handle the URL fine, but i have no idea how to handle returning a View object
public ActionResult Update(List<string> items, List<string> items2)
{
//if error return View
return Json(View("EditRoles", new AdminEditRolesViewModel(roles)), JsonRequestBehavior.AllowGet);
//if OK return new URL
return Json(RedirectToAction("EditRolesDetails"), JsonRequestBehavior.AllowGet);
}
The javascript looks like this:
$.ajax({
url: '/Admin/Update/',
data: { items: editedRoles, items2: $("#deleteList").sortable('toArray') },
success: function(data) {
window.location.href = data;
}
});
Which handles URLS fine if data looks like "/Controller/Action", just not sure how to handle something like a View that returns an object with
- RouteName
- RouteValues (Array of key/value pairs)
Thanks much