I have successfully implemented a JavaScript AJAX call that returns JSON data, and now I am trying to display it on my HTML page.
Here is the code snippet I am using:
success: function(response) {
console.log(response);
for (var i=0; i < response.length; i++) {
$('#main').append('<div class="name">' + response[i].name + '</div>');
}
},
error: function(response) {
alert(response);
}
});
Although the JSON data is being printed correctly in the console, nothing is appearing on the actual website.
I have already set up a div element to capture the data:
<div id="main">Test</div>
Can anyone help me figure out what I might be doing wrong?
EDIT: The response logged in the console looks like this:
{totalPages: 0, firstPage: true, lastPage: true, numberOfElements: 0, number: 0, …}
columns: {columnIds: Array(3)}
firstPage: true
lastPage: true
number: 0
numberOfElements: 0
oberonRequestXML: [null]
oberonResponseXML: [null]
summaryData: {totals: Array(3)}
totalElements: 0
totalPages: 0
__proto__: Object