title: JQuery POST redirect
body: <p>I have written a program in ASP.NET MVC and i have an issue with my AJAX function. </p>
  
  <p>If my function return success i want to redirect to another page , in POST Method. I cant use <code>window.location</code> so i have to make a form which will execute a post method.</p>
  
  <p>Here is my code : </p>
  
  <pre><code>&lt;body&gt;
  &lt;div class="login"&gt;
      &lt;div class="login-screen"&gt;
          &lt;div class="app-title"&gt;
              &lt;h1&gt;bla bla bla&lt;/h1&gt;
          &lt;/div&gt;
  
          &lt;div class="login-form"&gt;
              &lt;div class="control-group"&gt;
                  &lt;input type="text" class="login-field" value="" placeholder="bla bla bla" id="login-name"&gt;
                  &lt;label class="login-field-icon fui-user" for="login-name"&gt;&lt;/label&gt;
              &lt;/div&gt;
              &lt;div class="control-group"&gt;
                  &lt;input type="password" class="login-field" value="" placeholder="bla bla bla" id="login-pass"&gt;
                  &lt;label class="login-field-icon fui-lock" for="login-pass"&gt;&lt;/label&gt;
              &lt;/div&gt;
  
             &lt;input type="button" class="btn btn-primary" id="button" value="bla bla bla"/&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div id="failedLogin"&gt;
      &lt;/div&gt;
  
  &lt;/div&gt;
  &lt;/body&gt;
  
  &lt;script src="~/Scripts/Login.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>Here is m js code</p>
  
  <pre><code>$("#button").click(function () {
      $.ajax({
          url: "home/signIn",
          data: { userName: $("#login-name").val(), Password: $("#login-pass").val() },
          success: function (result) {
              if (result == "success") {
  
                  var redirect = function (url, method) {
                      $('&lt;form&gt;', {
                          method: method,
                          action: url
                      }).submit();
                  };
  
                  redirect('/Account/Menu?Name=' + $("#login-name").val(), 'post');
              }
              else {
                  var content = $("#failedLogin");
                  var label = "&lt;label class=\"result\"&gt;bla bla bla &lt;/label&gt;";
                  content.html(label);
              }
          }
      })
  </code></pre>
  
  <p>my c# code : </p>
  
  <pre><code>public string  signIn(string userName , string Password)
  {
      var db = new OsemEntities();
  
      var name= from u in db.*********
                  where u.UserName == userName &amp; u.UserPassword == Password
                  select u.UserName;
  
      if (name.Count() == 1)
          return "success";
      else
          return "fail";
  
  
  }
  </code></pre>
  
  <p>My post redirect doesnt work , i will glad to get some help.</p>
  
  <p>Thanks!</p>