Well I was aware of that but kept receiving error which I couldn’t de-bug so I was hoping there would be another simpler way. When I tried to use function you mentioned above I could not get any output in my console…
$(document).ready(function() {
console.log("Just before json");
$.getJSON('path to my php file', function(data) {
`console.log("Inside doing something");`
$(data).each(function(key, value) {
//do something
});
});;
})
I could never get any output of this code console.log("Inside doing something");
Then I found that I need to send headers like this…
header('Content-Type: application/json');
Which I did but then got error showing in the browser like this…
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
So that got me thingking maybe my JSON is incorrecto somehow so I went back to my php file and echoed it and grabbed that output and validated it here Validator JSON and it passed so right now I am at loss.