title: Redirect to another view using ajax call in mvc
body: <p>I have a registration form and on successful registration, it redirects to another view.
  I use a submit button to insert <strong>datas</strong> to database, I want to clear the values in the current view and redirect the user to <code>logon page</code> in another view under same controller.
  The submit type is not performing the action mentioned in jquery.Please help me </p>
  
  <p>here is my code preview</p>
  
  <p><strong><code>Account/register</code></strong></p>
  
  <p><strong><code>Account/logon</code></strong></p>
  
  <pre><code> Accountcontroller.cs
        [HttpPost]
       public ActionResult Register(RegisterModel model, FormCollection form)
        {
             try {
                  ---code
                 }
             catch {
             }
        }
  
  register.cshtml
       @using (Html.BeginForm("Register", "Account", FormMethod.Post, new { id = "accForm"      }))    
             {
               @html.textboxfor(.....)
               @html.textboxfor(.....)
               @html.textboxfor(.....)
               @html.textboxfor(.....)
                      ....
            &lt;input type="submit" value="CreateAccount" class="buttonclass"               title="CreateAccount" ; onclick="SaveUser(this);" 
  
               }
  
      function SaveUser(btnClicked) {
             alert("clear");
             document.getElementById("regname").value = '';
             document.getElementById("regusername").value = '';
             document.getElementById("regemail").value = '';
             document.getElementById("regpassword").value = '';
  
  
             document.getElementById("regpassword2").value = '';
  
             $.ajax({
                     url: window.location.pathname + '/Account/Logon',
  
                     type: 'GET',
                 })
                 .success(function (result) {
                      alert("user saved successfully");
                       });
  </code></pre>
  
  <p>UPDATE:
   </p>
  
  <pre><code>   function SaveUser(btnClicked) {
  
         document.getElementById("regname").value = '';
         document.getElementById("regusername").value = '';
         document.getElementById("regemail").value = '';
         document.getElementById("regpassword").value = '';
         document.getElementById("regpassword2").value = '';
         alert('clear');
     $.ajax({
  
  
            type: "POST",
             url:  window.location.pathname + "Account/Register",
  
             success: function (response) {
                 $.ajax({
                     url: window.location.pathname + '/Account/Logon',
                     type: 'GET',
                 })
          .success(function (result) {
              alert("user saved successfully");
  
              // window.location ="";
          });
             },
             error: function (xhr, status, error) {
                 alert("Failed");
             }
         });
  }
  </code></pre>
  
  <p>I'm getting a Failed alert.
  Please help</p>