title: Calling an ActionResult of Controller in Javascript
body: <p>I am trying to call an ActionResult inside the Controller in javascript.</p>
  <p>I have this ActionResult in my <code>AdminController</code>.</p>
  <pre><code>[HttpPost]
  public ActionResult Logout()
  {
      return RedirectToAction(&quot;Login&quot;, &quot;Login&quot;);
  }
  </code></pre>
  <p>This is my <code>Logout button</code> in AdminView.</p>
  <pre><code>&lt;a class=&quot;navbar-link&quot; id=&quot;logout&quot; name=&quot;logout&quot; href=&quot;#&quot;&gt;
      ログアウト
  &lt;/a&gt;
  </code></pre>
  <p>And try to create an event in JAVSCRIPT.</p>
  <pre><code>  $(&quot;#logout&quot;).click(function () {
          swal({
              title: &quot;ログアウト?&quot;,
              text: &quot;アカウントからサインアウトしますか？&quot;,
              icon: &quot;warning&quot;,
              buttons: true,
              dangerMode: true,
          })
              .then((willLogout) =&gt; {
                  if (willLogout) {
                      //swal(&quot;Poof! Your imaginary file has been deleted!&quot;, {
                      //    icon: &quot;success&quot;,
                      //});
                      $.ajax({
                          url: &quot;/Admin/Logout&quot;,
                          type: 'POST',
                          success: function (result) {
                              document.location.reload(true);
                          }, 
                          error: function (result) {
  
                          }
                      });
                  }
              });
      });
  </code></pre>
  <p>The main purpose of this is to redirect the user to Login Page using the Controller.</p>
  <p>I tried setting the <code>swal(&quot;Poof&quot;)...</code> inside the <code>.then(willLogout)</code> and it works.</p>
  <p>but when I use an ajax to call the ActionResult. It did not work.</p>
  <p>I saw the console and seems nothing is displayed.</p>
  <p>I don't know what am I doing wrong.</p>
  <p>How can I call the <code>ActionResult</code> from Controller to the Javascript file with <code>Ajax</code> call?</p>