title: javascript check if $_POST exist
body: <p>I have this scenario:</p>
  
  <ul>
  <li>in my index.html a form with a textbox and a button with method POST and action another page named middlescan.html</li>
  <li>middlescan.html that in body onload event call a js function named checkpost</li>
  <li>The js function into midlescan.html that have to check if a $_post variable is set or is not blank, in positive case make something, otherwise return to index.html</li>
  </ul>
  
  <p>My question is:
  How is possible in javascript check if a $_POST call was made??</p>
  
  <p>My situation now:</p>
  
  <ol>
  <li><p>In my index.html:</p>
  
  <pre><code>&lt;form id="form1" name="form1" method="post" action="middlescan.html"&gt;
  &lt;p&gt;
  &lt;label for="oStxt"&gt;&lt;/label&gt;
  &lt;/p&gt;
  &lt;table width="60%" border="0" cellspacing="0" cellpadding="0"&gt;
  &lt;tr&gt;
  &lt;td width="6%"&gt;&amp;nbsp;&lt;/td&gt;
  &lt;td width="17%"&gt;&lt;input type="text" name="oStxt" id="oStxt" /&gt;&lt;/td&gt;
  &lt;td width="77%"&gt;&lt;input type="submit" name="button" id="button" value="Invia" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/form&gt;
  </code></pre></li>
  <li><p>In middlescan.html</p>
  
  <pre><code>&lt;body onload = ckpost()&gt;
  </code></pre></li>
  </ol>
  
  <p>3.in js file</p>
  
  <pre><code>function ckpost() {
  
  // only continue if we have a valid xmlHttp object
  if (xmlHttp)
  {
  // try to connect to the server
  try
  {
    // initiate reading the async.txt file from the serve
  
    xmlHttp.open(“POST", "php/check.php", true);
    xmlHttp.onreadystatechange = handleRequestStateChange;
    xmlHttp.send(null);
    // change cursor to "busy" hourglass icon
  
  
  }
  // display the error in case of failure
  catch (e)
  {
    alert("Can't connect to server:\n" + e.toString());
  }
  }
  }
  </code></pre>
  
  <ol>
  <li><p>in my checkpost.php</p>
  
  <pre><code>&lt;?php
  $datat = array();
  
  if(!is_null($_POST['oStxt']) || $_POST['oStxt'] != "") {
  </code></pre>
  
  <p>$datat[urlpost] = $_POST['oStxt'];</p>
  
  <pre><code>} else {
  </code></pre>
  
  <p>$datat[urlpost] = "nullo";</p>
  
  <pre><code>} 
  </code></pre>
  
  <p>//Creo il file json 
  echo json_encode($datat);</p>
  
  <pre><code>?&gt;
  </code></pre></li>
  </ol>
  
  <p>but response is ever "nullo"
  What is wrong?</p>
  
  <p>Thanks in advance</p>