Ajax.BeginForm with OnComplete always updates page Ajax.BeginForm with OnComplete always updates page ajax ajax

Ajax.BeginForm with OnComplete always updates page


Use OnSuccess and get rid of UpdateTargetId. Like this:

@using (Ajax.BeginForm("Action", "Controller", new AjaxOptions { HttpMethod = "Post", OnSuccess = "foo" })){    ...}

and then:

function foo(result) {    if (result.SomePropertyThatExistsInYourJsonObject) {        // the server returned a JSON object => show the dialog window here    } else {        // the server returned a partial view => update the DOM:        $('#DivFormId').html(result);    }}