title: Strange situation, Visual Studio debugging ran through action to view but nothing returned to browser
body: <p>I have encountered a very strange problem.
  Basically, there is a <code>Delete ActionLink</code>. Once clicked, the code checks the condition, checks true/false, stays on current page or goes to <code>Delete view</code>. </p>
  
  <p>I have posted the solution for this scenario and got some very helpful replies. I worked on it and took it to a situation where I was about to succeed. </p>
  
  <p>Anyway, here are the codes</p>
  
  <p>Index View: AJAX calls the <code>Delete action</code>, returns JSON or EmptyResult. If EmptyResult, then it is a failure as the original ActionLink has been disabled, AJAX will call the <code>error</code> function, which calls another <code>action "Delete2"</code>.</p>
  
  <pre><code>&lt;td&gt;
                  @Html.ActionLink("Edit", "Edit", new { id = item.CustomerId }, htmlAttributes: new { @class = "mergo-actionlink" }) |
                  @Html.ActionLink("Details", "Details", new { id = item.CustomerId }, htmlAttributes: new { @class = "mergo-actionlink" }) |
                  @Html.ActionLink("Delete", "Delete", new { id = item.CustomerId }, htmlAttributes: new { @class = "mergo-actionlink-delete", data_value = item.CustomerId })
              &lt;/td&gt;
          &lt;/tr&gt;
      }
  
  &lt;/table&gt;
  
  &lt;script type="text/javascript"&gt;
      $('.mergo-actionlink-delete').click(
  function () {
      var clickedId = $(this).attr('data-value');
      $.ajax({
          dataType: "json",
          url: '@Url.Action("Delete", "Customers")',
          data: { id: clickedId},
          success: function (data) {
              alert(data.message);
          },
          error: function () {
              alert("EmptyResult returns.");
              debugger;
              $.post('@Url.Action("Delete2", "Customers")', { id: clickedId });
          },
          async: false
      });
      return false;
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>Controllers:</p>
  
  <pre><code>public ActionResult Delete(Guid? id)
  {
      if (id == null)
      {
          return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
      }
      Customer customer = db.Customers.Find(id);
      if (customer == null)
      {
          return HttpNotFound();
      }
  
      if (customer.Orders.ToList().Count() != 0)
      {
          return Json(new { message = "This customer has order(s) attached." }, "text/plain", JsonRequestBehavior.AllowGet);
      }
      return new EmptyResult();
  }
  
  public ActionResult Delete2(Guid? id)
  {
      if (id == null)
      {
          return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
      }
      Customer customer = db.Customers.Find(id);
      if (customer == null)
      {
          return HttpNotFound();
      }
      return View(customer);
  }
  </code></pre>
  
  <p>Delete2.cshtml</p>
  
  <pre><code>@model MergoMVC.Customer
  
  @{
      ViewBag.Title = "Delete";
  }
  
  &lt;h2&gt;Delete&lt;/h2&gt;
  
  &lt;h3&gt;Are you sure you want to delete this?&lt;/h3&gt;
  &lt;div&gt;
      &lt;h4&gt;Customer&lt;/h4&gt;
      &lt;hr /&gt;
      &lt;dl class="dl-horizontal"&gt;
          &lt;dt&gt;
              @Html.DisplayNameFor(model =&gt; model.UserName)
          &lt;/dt&gt;
  
          &lt;dd&gt;
              @Html.DisplayFor(model =&gt; model.UserName)
          &lt;/dd&gt;
  
          &lt;dt&gt;
              @Html.DisplayNameFor(model =&gt; model.Password)
          &lt;/dt&gt;
  
          &lt;dd&gt;
              @Html.DisplayFor(model =&gt; model.Password)
          &lt;/dd&gt;
  
          &lt;dt&gt;
              @Html.DisplayNameFor(model =&gt; model.Email)
          &lt;/dt&gt;
  
          &lt;dd&gt;
              @Html.DisplayFor(model =&gt; model.Email)
          &lt;/dd&gt;
  
      &lt;/dl&gt;
  
      @using (Html.BeginForm()) {
          @Html.AntiForgeryToken()
  
          &lt;div class="form-actions no-color"&gt;
              &lt;input type="submit" value="Delete" class="btn btn-default" /&gt; |
              @Html.ActionLink("Back to List", "Index")
          &lt;/div&gt;
      }
  &lt;/div&gt;
  </code></pre>
  
  <p>And I do have <code>Delete.cshtml</code> and <code>Delete2.cshtml</code> views for the actions. The symptom is - from debugging, Visual Studio went into <code>Delete2</code> action, returned the "customer" to <code>Delete2.cshtml</code> view, executed it from head to toe. But the browser stayed still on index page. I think something is wrong with the <code>return false;</code> in the AJAX. I'm new to this, so I need some help. Thanks.</p>