I have the following view , which contains an Ajax.BeginForm:-
@using (Ajax.BeginForm(\"ChangeDevicesSwitch\", \"Switch\", new AjaxOptions
{
InsertionMo
Return the url you want to make a redirect to from the action method when the operation succeeded:
public ActionResult ChangeDevicesSwitch(SwitchJoin s)
{
try
{
...
return Json(new { RedirectUrl = Url.Action("Details", new { id = s.GeneralSwitchTo }) });
}
...
}
And in the createsuccess
:
function createsuccess(data) {
if (data.RedirectUrl)
window.location.href = data.RedirectUrl;
}
in my case, following method was worked
function OnSuccess(data) {
var json;
if (data.responseText instanceof Object)
json = data.responseText;
else
json = $.parseJSON(data.responseText);
if (json.RedirectUrl)
window.location.href = json.RedirectUrl;
}