I want to get the simple table format from the json(results array) below, I wish to use jquery .each
. I tried this code but how to get the object? I tried v.subject but doesn't work.
$.getJSON( "http://127.0.0.1:8000/ajax/list/?page=1&format=json", function( data ) {
$.each( data, function() {
$.each( this, function( i, v ) {
console.log( v );
});
});
});
result of console.log(v)
Object { subject="ronald birthday", date="2014-06-13", time_start="11:17 PM"}
Object { subject="ronald birthday", date="2014-06-19", time_start="7:17 PM"}
This is the format table
<table >
<tr>
<td> <a href="#"> Rita Birthday</a> </td>
<td> <a href="#"> Oct. 18, 2014</a> </td>
<td> <a href="#"> 11:27 PM</a> </td>
</tr>
</table>
This is the json but only the results array should be in the table:
{"count": 18, "next": "http://www.nothingonlytest.com/ajax/list/?page=2&format=json", "previous": null, "results": [{"subject": "ronald birthday", "date": "2014-06-13", "time_start": "11:17 PM"}, {"subject": "ronald birthday", "date": "2014-06-19", "time_start": "7:17 PM"}, {"subject": "Rita Birthday", "date": "2014-10-18", "time_start": "11:27 PM"}, {"subject": "tt", "date": "2014-06-27", "time_start": "10:31 PM"}, {"subject": "tt", "date": "2014-06-13", "time_start": "10:31 PM"}, {"subject": "group event", "date": "2014-06-14", "time_start": "3:31 AM"}, {"subject": "test message", "date": "2014-06-17", "time_start": "3:32 AM"}, {"subject": "test event message", "date": "2014-06-14", "time_start": "3:34 AM"}, {"subject": "fd", "date": "2014-06-20", "time_start": "3:36 AM"}, {"subject": "fdf", "date": "2014-06-14", "time_start": "3:38 AM"}]}