title: Retrieving PHP JSON data through AJAX - correct structure of data request
body: <p>I have a PHP file called terminal_tester.php which runs a number of terminal actions and creates json data at the end using</p>
  
  <pre><code>echo json_encode($jsonData);
  </code></pre>
  
  <p>The data looks like this</p>
  
  <pre><code>{"source":"Betting Tips","published":"2015-05-20 15:20:22;","status":true,"eventIDs":["27448131","27448900"],"TipsTB":"TIP 1 MLADENOVIC TO BEAT RISKE\",\"TIP 2 DOLGOPOLOV TO BEAT GULBIS\"]","TipsTW":"[]"}
  </code></pre>
  
  <p>I now want to populate my HTML file with this data, but am having trouble understanding the correct format for the Ajax data input. I am trying the below in the script area of my html file</p>
  
  <pre><code>function callbackData(){
      return $.ajax({
          dataType: 'JSON',
          url: 'terminal_tester.php',
          type: 'GET',
          cache: false,
          data: jsonData
      });
  };
  
  callbackData().success(function (data) {
      document.getElementById("phpReturn2").innerHTML = jsonData
      document.getElementById("phpReturn3").innerHTML = eventIds
      document.getElementById("phpReturn4").innerHTML = published
  });
  </code></pre>
  
  <p>but I'm not getting any response. I've searched and I think the problem lies in the data: area of the ajax request but am also confused by the need of a GET command in the PHP file. Could somebody explain how to correctly structure the ajax request?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>terminal_tester.php has quite a few functions which come together at the end to build the json data, the final part of the php file looks like this</p>
  
  <pre><code>      $jsonData = createJson($eventIds, $TipsTB, $TipsTW, $status);
        echo json_encode($jsonData);
        $fp = fopen('results.json', 'w');
        fwrite($fp, json_encode($jsonData));
        fclose($fp);
  </code></pre>