<script type="text/javascript">
window.onload = function () {
var request;
if (window.XMLHttpRequest) {
//New browsers.
request = new XMLHttpRequest();
}
elseif (window.ActiveXObject) {
//Old IE Browsers.
request = new ActiveXObject("Microsoft.XMLHTTP");
}
if (request != null) {
request.open("GET", "https://raw.githubusercontent.com/aspsnippets/test/master/Customers.json", false);
request.onload = function () {
if (request.readyState == 4 && request.status == 200) {
var customers = JSON.parse(request.responseText);
//Create a HTML Table element.
var table = document.createElement("table");
table.border = "1";
//Add the header row.
var row = table.insertRow(-1);
//Add the header cells.
var headerCell = document.createElement("TH");
headerCell.innerHTML = "CustomerId";
row.appendChild(headerCell);
headerCell = document.createElement("TH");
headerCell.innerHTML = "Name";
row.appendChild(headerCell);
headerCell = document.createElement("TH");
headerCell.innerHTML = "Country";
row.appendChild(headerCell);
//Add the data rows.
for (var i = 0; i < customers.length; i++) {
//Add the data row.
var row = table.insertRow(-1);
//Add the data cells.
var cell = row.insertCell(-1);
cell.innerHTML = customers[i].CustomerId;
cell = row.insertCell(-1);
cell.innerHTML = customers[i].Name;
cell = row.insertCell(-1);
cell.innerHTML = customers[i].Country;
}
var dvTable = document.getElementById("dvCustomersGrid");
dvTable.innerHTML = "";
dvTable.appendChild(table);
}
};
request.send();
}
}
</script>