title: Javascript - redirect to a page with POST data
body: <p>I've got a page where the user can search (all in AJAX) in the database and select, let's say, different type of data on the page. When's he chosen them, what I need is to redirect the user to ANOTHER page (still on my website though), with POST data.
  The new page where the user will arrive needs that POST data, and the user needs to go to the new page.</p>
  
  <p>I've read that I could create a form before loading the page and simply submit it when I want to redirect, but the thing is that I don't have the data that will be included in the  before hand.</p>
  
  <p>I've tried doing something like this:</p>
  
  <pre><code>document.write('&lt;form id="reviseCombi" method="post" action="otherPage.php"&gt;&lt;input name="input1" type="hidden" value="ok" /&gt;&lt;input type="input2" type="hidden" value="'+ mots +'" /&gt;&lt;/form&gt;');
  f=document.getElementById('reviseCombi');
  if(f){
      f.submit();
  }
  </code></pre>
  
  <p>But the second input doesn't arrive to the new page when I check with Tamper Data. And it reloads the actual page first, which is weird too.</p>
  
  <p>Is there a better way to do it?</p>
  
  <p>EDIT: I got an answer for the input part. The page now gets the two inputs. But: it still reloads a blank page ONLY containing the form (and the html, body, etc.) and then it redirects. Any idea how I can have it directly?</p>
  
  <p>Sorry if it's not very clear, it's tough to explain. I'll answer any comments to explain it better.
  Thanks alot.</p>