JSFiddle - React, Tailwind, and code Playground
JavaScript
//json url get script
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : sParameterName[1];
}
}
};
//Variables
var dataTablePathVar = getUrlParameter('dataTablePath');
var insName = getUrlParameter('insuranceName');
var insNameFill = insName;
//Get school logo uri and append document title with school name
jQuery.ajax({
url: '../json/insuranceData.json',
async: true,
dataType: 'json',
error: function(result) {
//Error#1
console.log("Error#1: There was an error with loading the json for the school logo and name.");
},
success: function(data) {
var displaySchoolLogo = data.logoURI[0].logo;
$("#logo").append("<img src=" + displaySchoolLogo + " />");
document.title = "Report:" + " " + insName + " for " + data.schoolName[0].name;
}
});
//create tables
jQuery.ajax({
url: 'json/' + dataTablePathVar + '.json',
async: true,
dataType: 'json',
error: function(result) {
//Error#2
console.log("Error#2: There was an error populating the headers and footers.");
},
success: function(data) {
console.log("Creating the divs for all tables.");
for(i = 0; i < data.employeeInsuranceData.length; i++)
{
$("<div id='data" + i + "'>" +
"<div class='large-12 medium-12 small-12 columns' id=''>" +
...