dimanche 10 mai 2015

Ajax BeginForm target = _self still loads page when finished

I have an Ajax.BeginForm which is used to update some fields. However, after this call finishes, I just want the screen to stay as it is, but it keeps redirecting to the link defined in the BeginForm address.

I've added target = "_self" to no avail, it still keeps moving pages when the function completes.

Is there any way to stop this from happening? (maybe It's a missing javascript file or something?)

My HTML looks like this:

using (Ajax.BeginForm("Update", "Extraction", null, 
    new AjaxOptions { HttpMethod = "POST", OnSuccess = "saveSuccessful", 
    OnFailure = "saveFailed" }, new { target = "_self" }))

And the controller looks like this:

[HttpPost]
public void Update(Model model)
{
    // do work here
}

I've tried putting a debugger on the saveSuccessful javascript function and can see that this doesn't even get hit as the page already has moved to the page defined on BeginForm.

Aucun commentaire:

Enregistrer un commentaire