I'm not entirely sure how to word this properly, but, I want to be able to parse the "MoreData" json file.
Currently how I have it setup is.. I have a simple data table with first and last name and it reads from a external git JSON file. When I click on a row, depending on who I click on, it grabs the correct JSON data and opens a MODAL in bootstrap with the first and last name data from the JSON. However, I want to also inject into the same MODAL with data from the "MoreData" string. Is this possible to do?
{
"firstName": "John",
"lastName": "Smith",
"moreData": "https://raw.githubusercontent.com/test/test/main/jsmith-salaryinfo.json"
},
Don't mind my spaghetti code. I'm new to this, and trying to self learn. Any help would be greatly appreciated, and if you need more information please don't hesitate to ask. Thank you in advance!
$(document).ready(function() {
var table = $('#example').DataTable();
table;
$('#example').on('click', 'tr', function() {
let firstName = table.row(this).data().firstName
let lastName = table.row(this).data().lastName
document.getElementById('firstName').innerHTML = firstName + ' ' + lastName;
document.getElementById('lastName').innerHTML = firstName + ' ' + lastName;
$('#DescModal').modal("show");
// console.log(table.row(this).data());
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>