title: How to make redirect a User after they have submitted an Ajax call
body: <p>This is the View that I want the user to login on and then leave:</p>
  
  <pre><code>@model IEnumerable&lt;TerminalHost.Models.deviceInfo&gt;
  
  &lt;script&gt;
      $(document).ready(function () {
         $("#myTerminal").dialog({
          autoOpen: false,
          width: 550,
          height: 350,
          show: {
              effect: "fade",
              duration: 650
          },
          hide: {
              effect: "fade",
              duration: 600
          },
          buttons: {
              "OK": function () {
                      //Get he content from the input box
                      var uName = document.getElementById("usernameInput").value;
                      var pWord = document.getElementById("passwordInput").value;
                      var ipAddress = document.getElementById("ipAddressInput").value;
                      $.ajax({
                          type: "POST",
                          url: "/Terminal/terminalLogin",
                          data: { userN: uName, passW: pWord, ipAd: ipAddress},  // pass the data to the method in the Terminal Contoller
                          success: function (data) {
                              window.location.href = data.redirectToUrl;
                          },
                          error: function (e) { alert(e); }
                      })
                  },
              "Cancel": function (e) {
                  $("#myTerminal").dialog("close");
              }
          }
      });
  
  
      $("#terminalAccess").click(function form() {
          $("#myTerminal").dialog("open");
      });
  });
  
  function onSuccess() {
      $("#myTerminal").dialog("close");
  }
  &lt;/script&gt;
  
  &lt;div id="myTerminal" title="Terminal Login"&gt;
      &lt;label for="username"&gt;Username&lt;/label&gt;
      &lt;input type="text" name="passwordInput" id="usernameInput" /&gt;
      &lt;label for="password"&gt;Password&lt;/label&gt;
      &lt;input type="password" name="password" id="passwordInput" /&gt;
      &lt;label for="ipAddress"&gt;Ip Address&lt;/label&gt;
      &lt;input type="text" name="ipAddress" id="ipAddressInput" /&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>This is the View that the user will go too:</p>
  
  <pre><code>@{
      ViewBag.Title = "Terminal";
  }
  &lt;script&gt;
    $(document).ready(function () {
      $("#cmdSend").click(function () {
          // Get he content from the input box
          var mydata = document.getElementById("cmdInput").value;
          $.ajax({
              type: "POST",
              url: "/Terminal/processCommand",
              data: { cmd: mydata },  // pass the data to the method in the Terminal Contoller
              success: function (data) {
                  //alert(data);
                  // we need to update the elements on the page
                  var existingHtml = $(".terminal").html();
                  $(".terminal").append("&lt;/br&gt;" + "-&gt;" + mydata + "&lt;/br&gt;" + data);
              },
              error: function (e) { alert(e); }
          })
      });
  });
  &lt;/script&gt;
  &lt;h3&gt;Terminal for device: *Device name*&lt;/h3&gt;
  &lt;ol class="round"&gt;
  &lt;li&gt;
  
      &lt;article&gt;
          &lt;div class="terminal" style="overflow-y: scroll;" &gt;&lt;/div&gt;
          &lt;div class="terminalInputArea"&gt;
              &lt;div class="inputBox"&gt;
               &lt;input id="cmdInput" /&gt;&lt;button type="button" id="cmdSend"&gt;Send&lt;/button&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/article&gt;
  
  &lt;/li&gt;
  &lt;/ol&gt;
  </code></pre>
  
  <p>and this is the controller that I want the data to be sent to:</p>
  
  <pre><code> public class TerminalController : Controller
  {
      SSH ssh = new SSH();
  
      [HttpPost]
      public ActionResult terminalLogin(string userN, string passW, string ipAd)
      {
          ssh.username = userN;
          ssh.password = passW;
          ssh.ipAddress = ipAd;
  
          if (Request.IsAjaxRequest())
          {
              return Json(new { redirectToUrl = Url.Action("Terminal") });
          }
          return RedirectToAction("Terminal");
      }
  
      [HttpPost]
      public string processCommand(string cmd)
      {
          ssh.cmdInput = cmd;
          String info = ssh.SSHConnect();
          info = info.Replace("!", "&lt;br&gt;");
          return info;
      }
  
      public ActionResult Terminal()
      {
          return View();
      }
  
  }
  </code></pre>
  
  <p>I didn't include the model as I figure its not the problem but I can add it. The model is called SSH.cs</p>