I am new to JSON. I have data.json, jQuery.min.js and try.html files within a folder. The problem is that it doesn't show any output on the screen. I also tried some of the examples from other websites as well as StackOverflow too, but the problem remains the same. Please help me out.
try.html :
<body>
<div id="append-here"></div>
<script type="text/javascript" src="jquery-2.1.4.min.js"></script>
<script>
$(document).on('ready', function(){
$.getJSON('data.json', function (data) {
$.each(data, function(index, element) {
$('#append-here').append(element.name);
});
});
});
</script>
data.json :
[
{ "id" : "1", "name" : "test1" },
{ "id" : "2", "name" : "test2" },
{ "id" : "3", "name" : "test3" },
{ "id" : "4", "name" : "test4" },
{ "id" : "5", "name" : "test5" }
]
And this is what I get on JS console:
XMLHttpRequest cannot load file:///C:/Users/avi/Desktop/html/jsAjax/data.json. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.