Trying to populate 2 areas of a section from a JSON response. The response works and outputs the following, however when I try to use data[0] and data[1] to get the title, text and image it doesn't want to. I am getting the data back correctly, just can't seem to add it in.The console.log response is undefined.
JSON Response:
[{"title":"Title 1","text":"Text 1","image":"Image 1"},{"title":"Title 2","text":"Text 2","image":"Image 2"}]
jQuery code:
$.get( 'test-api.php?eventQuery', { answers }, function( data, status ) {
console.log(data[0].title);
// Populate both sections with returned data
});
stringor as ajson? Did you tried to useJSON.parse(data)?getJSONinstead.