Here is one way to do it.
- You need to get the table object using jquery selector.
- Then you need to loop the results property of the json data using for keyword.
- For each object of the result, get the property of subject, date and time_start using property accessor.
- Create a row string such as
"<tr><td>" + val1 + "</td><td>" + val2 + "</td><td>" + val3 + "</td></tr>"
and append it to the table object using jquery append.
UPDATE
You need to loop the results property instead.
$.getJSON("http://127.0.0.1:8000/ajax/list/?page=1&format=json", function( data ) {
$.each(data.results, function() {
$.each( this, function( i, v ) {
console.log( v );
});
});
});
1
solved jquery json inside array to html table [closed]