jquery json to table

Solutions on MaxInterview for jquery json to table by the best coders in the world

showing results for - "jquery json to table"
Marina
27 Jul 2017
1$.ajax({
2    type: "GET",
3    url: "data.json",
4    dataType: 'json',
5    success: function (data) {
6        $('body').append(arrayToTable(data));
7    }
8});
9
Michele
16 Aug 2016
1<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
Gaël
09 Jan 2018
1function arrayToTable(tableData) {
2    var table = $('<table></table>');
3    $(tableData).each(function (i, rowData) {
4        var row = $('<tr></tr>');
5        $(rowData).each(function (j, cellData) {
6            row.append($('<td>'+cellData+'</td>'));
7        });
8        table.append(row);
9    });
10    return table;
11}
12
13$('body').append(arrayToTable([
14    ["John","Slegers",34],
15    ["Tom","Stevens",25],
16    ["An","Davies",28],
17    ["Miet","Hansen",42],
18    ["Eli","Morris",18]
19]));