Reputation: 3816
I am trying to access JSON data from separate json file(in different folder)but it is throwing exception " No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. "
I have my file at root "Index.html".Parallel to this there is a separate folder "JSON" which contains my json file "quotes.json". My Code is
$(document).on("pagebeforeshow", "#info-page", function () {
$.getJSON("Json/quotes.json", function (data) {
var items = [];
$.each(data, function (key, val) {
items.push(val);
alert(data.key);
});
});
});
Upvotes: 0
Views: 216
Reputation: 38112
You need to create a json file with name quotes.json
instead of quotes.html
and put your json code inside this file.
Upvotes: 0