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);
});
});
});
您需要创建一个名称为quotes.json
而不是quotes.html
的json文件,并将您的json代码放入该文件中。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.