I'm developing an application here, and I use a JSON object for popular, but when I use $.getJSON()
Chrome gives the following error:
XMLHttpRequest can not load file: /// C: /Users/JeanCarlos/Documents/GitHub/NetworkDiagram/Application/Object.json. Cross source requests are only supported for protocol schemes: http, date, chrome, chrome-extension, https, chrome-extension-resource.
JavaScript
$(function() {
// This function get error XMLHtmlRequest, because this not supported protocol LOCAL.
$.getJSON('Object.json', function(data) {
console.log('success');
var table = '';
$.each(data.activies, function(key, val) {
table += '<table>';
table += '<tbody>';
table += '<tr><td>' + val.EarlyStart + '</td><td>' + val.Duration + '</td><td>' + val.EarlyFinish + '</td></tr>';
table += '<tr><td colspan="3">' + val.ActivityName + '</td></tr>';
table += '<tr><td>' + val.LateStart + '</td><td>' + val.TotalFloat + '</td><td>' + val.LateFinish + '</td></tr>';
table += '</tbody>';
table += '</table>';
});
$("#content").append(table);
}).error(function() {
console.log('error');
});
});
Object.JSON
{"activies" = [{
"EarlyStart": "1",
"Duration": "10",
"EarlyFinish": "2",
"ActivityName": "Activity 1",
"LateStart": "4",
"TotalFloat": "4",
"LateFinish": "5"
}]}
I understand the problem, that this error is a "half security" that chrome uses, but I need to modify this code to not give this problem anymore.