title: javascript/http post request without redirecting to the website
body: <p>I am trying to allow users to log into a different/external website that allows Cross-Origin Resource Sharing.</p>
  
  <p>This is my html for password and username:</p>
  
  <pre><code>&lt;form action="http:...../login/login.cfm" method="post"&gt; 
  &lt;input type="text" placeholder="username" id="username" name="username" &gt;&lt;br&gt;
  &lt;input type="password" placeholder="password" id="password" name="password"&gt;
  &lt;button onclick= "test()"&gt;Save &amp; Enter&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>This does log you in to the site but it also redirects you to the page that opens up after you log in. How do I just log the user in and then GET a string from a web page. </p>
  
  <p>Also I could use the get request to validate the password because if it cannot GET the information then the person entered the wrong username or password.</p>
  
  <p>So how do a I do a password and username post without redirecting to the site?
  PLEASE HELP.
  (This is all client side, Javascript, jquery, and html only. No php.)</p>
  
  <pre><code>&lt;form&gt; 
  &lt;input type="text" placeholder="username" id="username" name="username" &gt;&lt;br&gt;
  &lt;input type="password" placeholder="password" id="password" name="password"&gt;
  &lt;button onclick= "test()"&gt;Save &amp; Enter&lt;/button&gt;
  &lt;/form&gt; 
  &lt;script&gt;
  var username = document.getElementById("username").value;
  var password = document.getElementById("password ").value;
  $.post( "http://.../login/login.cfm", { name: username, password: password })
    .done(function( data ) {
      alert( "Data Loaded: " + data );
    });
  &lt;/script&gt;
  </code></pre>
  
  <p>This does not work.</p>
  
  <p>Here is an example:</p>
  
  <pre><code>username=daniel&amp;password=password
  </code></pre>