I'm trying to load a local JSON file to populate a table with it. I've tried requireJS, but it gave me an error:
MODULE NAME ... HAS NOT BEEN LOADED YET FOR CONTEXT
So I installed the requireJS plugins with bower, though I'm not sure if they are working correctly. This is the code:
<script src="require.js"></script>
<script>
function populate() {
require(['json!sortedAccounts.json'], function (json) {
for (var i = 0; i < json.length; i++) {
var $row = "<tr>"
var account = json[i][0]
$row.append("<td>" + account + "</td>")
var friends = json[i][1]
$row.append("<td>" + friends + "</td>")
$row.append("</tr>")
$('loadedJSON').append($row)
}
});
}
</script>
The error I get is:
GET http://localhost:63343/HTML/json.js
Uncaught Error: Script error for "json", needed by: json!sortedAccounts.json_unnormalized2 Uncaught Error: Load timeout for modules: json!sortedAccounts.json_unnormalized2