title: Using JQuery to get JSON response from PHP
body: <p>I have accumulated and chopped up about 5 or 6 different tutorials of this now, and I still can't find out what's wrong!</p>
  
  <p>Using JQuery Mobile (phonegap) to send and receive data to a PHP server. I cannot seem to get the JQuery script to pick up a response. 
  PHP on server:</p>
  
  <pre><code>&lt;?php
  
  // Set up associative array
  $data = array('success'=&gt; true,'message'=&gt;'Success message: worked!');
  
  // JSON encode and send back to the server
  echo json_encode($data);
  
  ?&gt;
  </code></pre>
  
  <p>JQuery Function (Which is being called):</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(function () {
      $('#inp').keyup(function () {
          var postData = $('#inp').val();
          $.ajax({
              type: "POST",
              dataType: "json",
              data: postData,
              beforeSend: function (x) {
                  if (x &amp;&amp; x.overrideMimeType) {
                      x.overrideMimeType("application/json;charset=UTF-8");
                  }
              },
              url: 'removedmyurlfromhere',
              success: function (data) {
                  // 'data' is a JSON object which we can access directly.
                  // Evaluate the data.success member and do something appropriate...
                  if (data.success == true) {
                      alert('result');
                      $('.results').html(data.message);
                  } else {
                      $('.results').html(data.message);
                  }
              }
          });
      });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>Sorry for the formatting, it all went pair shaped copying it across. Removed my url.</p>
  
  <p>I know that the function is firing, because if I remove the alert('here'); and put it above the ajax call it displays. </p>
  
  <p>Anybody know why the success function isn't calling? nothing shows in the div with class results on any browser.</p>
  
  <p>Thanks!</p>