title: jQuery Ajax error 200 parse error
body: <p>I have read many articles related to my predicament but I do not understand my what my problem is so please someone help explain it to me:</p>
  
  <p>I want to use jQuery ajax to post a value to a PHP file:</p>
  
  <pre><code>$().ready(function(){
  "use strict";
  $("#ansSubmit").click(function() {
      $.ajax({
          type: "POST",
          url: "updateScore.php",
          dataType: "json",
          data:{ 
              data : JSON.stringify(flag)
          },
          success: function(data) {
              alert(data.reply);
          },
          error: function(jqXHR, textStatus, errorThrown) {
            alert("jqXHR: " + jqXHR.status + "\ntextStatus: " + textStatus + "\nerrorThrown: " + errorThrown);
          }
      });  
      $("#infoDiv").load("updateScore.php"); // to see what $_POST contains
    });
  });
  </code></pre>
  
  <p>The flag variable being sent is an integer. </p>
  
  <p>Here is my updated updateScore.php (the PHP file I am posting to):</p>
  
  <pre><code>&lt;?php
  session_start();
  
  $returned = array("reply" =&gt; "no data received");
  
  if(isset($_POST["data"])) {
     $returned["reply"] = $_POST["data"];
  }
  
  print_r($_POST);
  
  echo json_encode($returned);
  
  ?&gt;
  </code></pre>
  
  <p>"no data received" is returned so at least I know it reached updateScore.php but now I need help establishing why it not sending anything through - I am 100% sure flag has a value.</p>
  
  <p>Additional information:</p>
  
  <ol>
  <li>mime.types has all JSON options active. </li>
  <li>console.log(data) returns Uncaught Reference Error: data is not defined.</li>
  <li>errorThrown returns Parse error: unexpected &lt; in position 0 - I can get this to say unexpected A in position 0 but it is still an empty array that is being sent.</li>
  <li>print_r($_POST) returns Array()</li>
  </ol>