title: ASP.NET MVC4 AJAX.BeginForm AjaxOptions OnSuccess not called
body: <p>I'm trying to use Jquery Model Dialog in MVC4 using Razor dialog box showing fine but  AjaxOptions.OnSuccess javascript function is not calling after i click the update button but it's redirected to  http://&lt;>:3738/Cars/Edit/1?Length=4 i don;t know why it was happened.</p>
  
  <p>Here is my Code</p>
  
  <p>CarController.cs</p>
  
  <pre><code>public class CarsController : Controller
  {
      private ExpDb db = new ExpDb();
  
      //
      // GET: /Cars/
  
      public ActionResult Index()
      {
          return View(db.Cars.ToList());
      }
  
  
  
      //
      // GET: /Cars/Edit/5
  
      public ActionResult Edit(int id = 0)
      {
          CarModel carmodel = db.Cars.Find(id);
          if (carmodel == null)
          {
              return HttpNotFound();
          }
          return PartialView(carmodel);
      }
  
      //
      // POST: /Cars/Edit/5
  
      [HttpPost]
      public JsonResult  Edit(CarModel carmodel)
      {
          if (ModelState.IsValid)
          {
  
              db.Entry(carmodel).State = EntityState.Modified;
              db.SaveChanges();
              //return RedirectToAction("Index");
               return Json(JsonResponseFactory.SuccessResponse(carmodel),JsonRequestBehavior.DenyGet);
          }
        else {
              return Json(JsonResponseFactory.ErrorResponse("Please review your form"), JsonRequestBehavior.DenyGet);
          }
      }
  </code></pre>
  
  <p>Index.cshtml</p>
  
  <pre><code>@model IEnumerable&lt;AjaxSamples.Models.CarModel&gt;
  
  @{
  ViewBag.Title = "Index";
  }
  &lt;div id="commonMessage"&gt;&lt;/div&gt;
  &lt;p&gt;
  @Html.ActionLink("Create New", "Create")
  &lt;/p&gt;
  &lt;table&gt;
  &lt;tr&gt;
      &lt;th&gt;
          @Html.DisplayNameFor(model =&gt; model.ImageFileName)
      &lt;/th&gt;
      &lt;th&gt;
          @Html.DisplayNameFor(model =&gt; model.Name)
      &lt;/th&gt;
      &lt;th&gt;
          @Html.DisplayNameFor(model =&gt; model.Description)
      &lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
  &lt;/tr&gt;
  
  @foreach (var item in Model) {
  &lt;tr&gt;
      &lt;td&gt;
          @Html.DisplayFor(modelItem =&gt; item.ImageFileName)
      &lt;/td&gt;
      &lt;td&gt;
          @Html.DisplayFor(modelItem =&gt; item.Name)
      &lt;/td&gt;
      &lt;td&gt;
          @Html.DisplayFor(modelItem =&gt; item.Description)
      &lt;/td&gt;
      &lt;td&gt;
          @Html.ActionLink("Edit", "Edit", new { id = item.Id }, new { @class = "editLink" }) |
          @Html.ActionLink("Details", "Details", new { id=item.Id }) |
          @Html.ActionLink("Delete", "Delete", new { id=item.Id })
  
          &lt;button id="opener"&gt;Open Dialog&lt;/button&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
  
  
  
   }
  
  &lt;/table&gt;
  
   &lt;div id="updateDialog" title="Update Car"&gt;&lt;/div&gt;
   &lt;script type="text/javascript"&gt;
   var linkObj;
   $(function () {
      $(".editLink").button();
  
      $('#updateDialog').dialog({
          autoOpen: false,
          width: 400,
          resizable: false,
          modal: true,
          buttons: {
              "Update": function () {
                  $("#update-message").html(''); //make sure there is nothing on the message before we continue                         
                  $("#updateCarForm").submit();
              },
              "Cancel": function () {
                  alert('sd');
                  $(this).dialog("close");
              }
          }
      });
  
      $(".editLink").click(function () {
          //change the title of the dialog
          linkObj = $(this);
          var dialogDiv = $('#updateDialog');
          var viewUrl = linkObj.attr('href');
          $.get(viewUrl, function (data) {
              alert(data);
              dialogDiv.html(data);
              //validation
              var $form = $("#updateCarForm");
              // Unbind existing validation
              $form.unbind();
              $form.data("validator", null);
              // Check document for changes
              $.validator.unobtrusive.parse(document);
              // Re add validation with changes
              $form.validate($form.data("unobtrusiveValidation").options);
              //open dialog
              dialogDiv.dialog('open');
          });
          return false;
      });
  
  });
  function err(data) {
      alert(data);
  }
  
  
   function updateSuccess(data) {
      alert(data);
  }
  </code></pre>
  
  <p></p>
  
  <p>Edit.cshtml</p>
  
  <pre><code>@model AjaxSamples.Models.CarModel
  
  @{
  ViewBag.Title = "Edit";
  }
  
  @using (Ajax.BeginForm("Edit", "Cars", new AjaxOptions
      {
          InsertionMode = InsertionMode.Replace, 
          HttpMethod = "POST",
          OnSuccess = "updateSuccess"
      }, new { @id = "updateCarForm" }))
   {
   @Html.ValidationSummary(true)
  &lt;div id="update-message" class="error invisible"&gt;&lt;/div&gt;
  &lt;fieldset&gt;
      &lt;legend&gt;CarModel&lt;/legend&gt;
  
      @Html.HiddenFor(model =&gt; model.Id)
  
      &lt;div class="editor-label"&gt;
          @Html.LabelFor(model =&gt; model.ImageFileName)
      &lt;/div&gt;
      &lt;div class="editor-field"&gt;
          @Html.EditorFor(model =&gt; model.ImageFileName)
          @Html.ValidationMessageFor(model =&gt; model.ImageFileName)
      &lt;/div&gt;
  
      &lt;div class="editor-label"&gt;
          @Html.LabelFor(model =&gt; model.Name)
      &lt;/div&gt;
      &lt;div class="editor-field"&gt;
          @Html.EditorFor(model =&gt; model.Name)
          @Html.ValidationMessageFor(model =&gt; model.Name)
      &lt;/div&gt;
  
      &lt;div class="editor-label"&gt;
          @Html.LabelFor(model =&gt; model.Description)
      &lt;/div&gt;
      &lt;div class="editor-field"&gt;
          @Html.EditorFor(model =&gt; model.Description)
          @Html.ValidationMessageFor(model =&gt; model.Description)
      &lt;/div&gt;
  
      &lt;p&gt;
          &lt;input type="submit" value="Save" /&gt;
      &lt;/p&gt;
  &lt;/fieldset&gt;
  }
  
  &lt;div&gt;
  @Html.ActionLink("Back to List", "Index")
  &lt;/div&gt;
  </code></pre>