title: Send POST data on redirect with JavaScript/jQuery?
body: <p>Basically what I want to do is send <code>POST</code> data when I change the <code>window.location</code>, as if a user has submitted a form and it went to a new page. I need to do it this way because I need to pass along a hidden URL, and I can’t simply place it in the URL as a <code>GET</code> for cosmetic reasons.</p>
  
  <p>This is what I have at the moment, but it doesn’t send any POST data.</p>
  
  <pre><code>if(user has not voted) {
  
      window.location = 'http://example.com/vote/' + Username;
  
  }
  </code></pre>
  
  <p>I know that you can send <code>POST</code> data with <code>jQuery.post()</code>, but I need it to be sent with the new <code>window.location</code>. </p>
  
  <p>So to recap, I need to send <code>api_url</code> value via <code>POST</code> to <code>http://example.com/vote/</code>, while sending the user to the same page at the same time.</p>
  
  <hr>
  
  <p><strong>For future reference, I ended up doing the following</strong>:</p>
  
  <pre><code>if(user has not voted) {
  
      $('#inset_form').html('&lt;form action="http://example.com/vote/' + Username + '" name="vote" method="post" style="display:none;"&gt;&lt;input type="text" name="api_url" value="' + Return_URL + '" /&gt;&lt;/form&gt;');
  
      document.forms['vote'].submit();
  
  }
  </code></pre>