The title says it all, I'm struggling to get data from a json file to an HTML table using a js function with jquery, but the data from the json file isn't loading onto the table. I'm also using bootstrap. I got the error Access to XMLHttpRequest at 'file:///C:/Users/Nuno/Desktop/my%20shit/Faculdade/ITW/trabalho%20lab/info.json' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.
JSON:
[
{"Age": "18", "Email": "[email protected]", "Phone": "123456789", "Adress": "Lisbon", "Languages": "English, Portuguese, (Limited) Spanish"}
]
JS:
$(document).ready(function(){
$.getJSON("info.json", function(data){
var mydata = '';
$.each(data, function(key,value){
mydata += '<tr>';
mydata+= '<td>'+value.age+'</td>';
mydata+= '<td>'+value.email+'</td>';
mydata+= '<td>'+value.phone+'</td>';
mydata+= '<td>'+value.adress+'</td>';
mydata+= '<td>'+value.languages+'</td>';
mydata += '</tr>';
});
$('#personalInfo').append(mydata);
});
});
HTML:
<div class="table-responsive">
<table class="table table-bordered table-striped" id="personalInfo">
<tr>
<th>
Age
</th>
<th>
Email
</th>
<th>
Phone
</th>
<th>
Adress
</th>
<th>
Languages
</th>
</tr>
</table>
</div>