While I have a good grasp of PHP, diving into AJAX and dealing with JSON is proving to be quite challenging for me.
My PHP script simply delivers a straightforward JSON string like this:
{"bindings": [ {"ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*"},
{"ircEvent": "PRIVMSG", "method": "deleteURI", "regex": "^delete.*"},
{"ircEvent": "PRIVMSG", "method": "randomURI", "regex": "^random.*"} ] } I
I fetch it using the following code:
var fillDataMasterTable = $.ajax({
url: "/php/PrepareGoogleDataTable.php" +"?"+
"SensorString="+SensorString + "&"+
"TableType=" + TableType +"&"+
"NoAbscissaBins=" + NoAbscissaBins + "&"+
"DataTableName=" + DataTableName +"&"+
"TimeUnit=" + TimeUnit +"&"+
"TimeStart=" + TimeStart,
dataType:'json',
async: false
}).responseText;
$('#debug_div').html(fillDataMasterTable);
Retrieving the JSON string works fine, but my struggle begins when trying to access individual values. I attempted:
$('#debug_div').html(fillDataMasterTable.bindings);
However, this approach doesn't yield the desired results. Admittedly, I may be making a fundamental mistake here, and I am open to guidance in order to kickstart my understanding.