I have a PHP file called terminal_tester.php which runs a number of terminal actions and creates json data at the end using
echo json_encode($jsonData);
The data looks like this
{"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":"[]"}
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
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
});
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?
EDIT
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
$jsonData = createJson($eventIds, $TipsTB, $TipsTW, $status);
echo json_encode($jsonData);
$fp = fopen('results.json', 'w');
fwrite($fp, json_encode($jsonData));
fclose($fp);