function generateHtmlRow(repoData) { var html = ""; html+="" + repoData.name + ""; html+="" + repoData.forks + ""; html+="" + repoData.language + ""; html +=""; return html; } function createOrgTable(orgName, tableContainer) { var html = ""; queryAPIByOrg(API_REPOSITORIES, orgName, function(data) { for(var i=0; i < data.length; i++) { html += generateHtmlRow(data[i]); } $("#" + tableContainer).html(html); $('#dataTable').DataTable(); }, function(error) { console.log("Unable to load table data"); }); }