JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<table id="fixtures">
<thead>
<tr>
<th>Home</th>
<th>Away</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
CSS
table {
background: #DDD;
}
thead tr {
background: #9D9;
}
tbody tr:nth-child(2n) {
background: #CFC;
}
tbody tr:nth-child(2n+1) {
background: #EFE;
}
th, td {
width: 100px;
padding: 0.2em;
text-align: center;
}
JavaScript
var jsonDataUrl = 'http://bushell.net/football/site/includes/functions.php';
$(function() {
$.ajax({
type: 'GET',
url: jsonDataUrl,
async: false,
jsonpCallback: 'JSON_CALLBACK',
contentType: "application/json",
dataType: 'json',
success: function(data) {
addRows($('#fixtures'), data, ['data.homeTeamName','data.awayTeamName']);
},
error: function(e) {
console.log(e.message);
}
});
});
function addRows(table, data, fields) {
var tbody = table.find('tbody');
$.each(data, function(i, item) {
tbody.append(addRow(item, fields));
});
return tbody;
}
function addRow(item, fields) {
var row = $('<tr>');
$.each(fields, function(i, field) {
row.append($('<td>').html(item[field]));
});
return row;
}