title: MVC4: skip ajax success and redirect to another view from model
body: <p>I have a functionality where based on condition I am showing jQuery dialog box. If condition is false just need to redirect to another view with refresh reload. 
  It is working fine for jQuery dialog and loading partial view. </p>
  
  <p>But when condition fails I am RedirectToAction("Index") which is suppose to load fresh. But is loading again in jQuery dialog. which means Ajax call back success calling back. </p>
  
  <p>my question is how to avoid jquery ajax success call back and skip completely.</p>
  
  <p>here is the code.</p>
  
  <pre><code> $.ajax({
          url: 'SaveAddress',
          type: 'Post',
          cache: false,
          data: $("#frmAddress").serialize(),
          success: function (data) {
  
              $("#dialogPopSuggestions").dialog({
                  autoOpen: false,
                  height: 600,
                  width: 500,
                  modal: true,
                  title: "Suggesion Addresses",
                  //dialogClass: 'warning-dialog',
                  open: function (event, ui) {
                      //Load the  action which will return 
                      // the partial view 
                      $(this).html(data);
                      event.preventDefault();
                      event.stopPropagation();
                  }
              });
              $("#dialogPopSuggestions").dialog("open");
          },
          error: function (xhr, ajaxOptions, thrownError) {
              alert("error occured");
          }
  
    [HttpPost]
      public ActionResult SaveAddress(FormCollection col)
      {
             ....
             ....
              if (addresssuggestionList.Count == 0) //no suggestion
          {
              memberAddressDetails = memberAddress.AddAddress(memberId, memberAddressDetails);
          }
          else
          {
              addresssuggestionList.Add(memberAddressDetails);
              ViewBag.IsPrimaryCompany = primaryCompany;
              ViewBag.IsPrimaryAddress = mainAddress;
              return PartialView("_PopDivSuggestionAddress", addresssuggestionList); //Jquery dialog loads perfect
          }
          return RedirectToAction("Index");//here suppose fresh load index, not jQuery dialog.
      }
  </code></pre>