title: jQuery POST Upon Button Click not Working
body: <p>I have a problem with a function that is called when a button is clicked.</p>
  
  <p><strong>Javascript :</strong></p>
  
  <pre><code>function sendData(){
       $.post("send.php",
           {
            type: "A",
            val: "answer"
          },
          function(data,status){
              alert(data);
          });
  }
  </code></pre>
  
  <p><strong>HTML :</strong></p>
  
  <pre><code>&lt;div id="testButton" onclick="sendData();"&gt;click&lt;/div&gt;
  </code></pre>
  
  <p><strong>PHP :</strong></p>
  
  <pre><code>&lt;?php
      foreach ($_POST as $key =&gt; $value)
      {
          echo $value
      }
  ?&gt;
  </code></pre>
  
  <p>I post the data to the php page and expect to receive the data back. The javascript should alert the data upon a successful call.</p>
  
  <p>When the button is clicked, nothing happens. </p>
  
  <p>Please can someone see if there is anything wrong with the code.</p>