title: How to post a variable value from javascript to PHP?
body: <p>I am using JavaScript to pass a variable to another php file.  I have a value in javascript, and I want to pass it as a post variable to another php file.</p>
  
  <p>Javascript code:</p>
  
  <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;script type="text/javascript" src="js/jquery.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" &gt;
  
  //Important code here to post a variable to bh.php:
  $(document).ready(function(){
    $('#op_comp_id').load('bh.php').show();
      $('#get_value_id').keyup(function() {
      $.post('bh.php', { id: form.get_value.value },
          function(result){
              $('#op_comp_id').html(result).show();
              });  
      });
  });
  &lt;/script&gt;
  
  &lt;/head&gt; 
  &lt;body&gt;
  &lt;?$id = $_GET['id'];?&gt;
  &lt;form  name="form"&gt;
  &lt;input type="text" id="get_value_id" name="get_value" value="&lt;?php echo $id ?&gt;"&gt;
  &lt;/input&gt;
  &lt;/form&gt;
  
  &lt;div id="op_comp_id"&gt;&lt;/div&gt; 
  
  &lt;/body&gt; 
  &lt;/html&gt;
  </code></pre>
  
  <p>This was my attempt to pass a variable value from javascript to <code>bh.php</code> in post mode.  </p>
  
  <pre><code>bh.php?id=value
  </code></pre>
  
  <p>Is there an alternative way or better way to do this?</p>