[英]How to get data by json file
i have json file which is hosted on the server. 我有托管在服务器上的json文件。 this is the link.
这是链接。
http://jsonji.azurewebsites.net/json1.json , http://jsonji.azurewebsites.net/json1.json ,
and i am able to get json data when this file is on the my local system. 当这个文件在我的本地系统上时,我能够获取json数据。 this is the code
这是代码
$(document).ready(function () {
$.getJSON("http://jsonji.azurewebsites.net/json1.json",
function (data) {
$.each(data.person, function () {
$("ul").append("<li> Name:" + this['name'] + "</li><li>Age" + this['age'] + "</li><br/>");
});
});
});
if you know then please help me 如果知道的话请帮帮我
The reason you're not able to read this JSON file is because you're browser is trying to make a cross-domain request and most likely CORS Setting is not enabled on your website. 之所以无法读取此JSON文件,是因为您正在浏览器尝试进行跨域请求,并且很可能在您的网站上未启用CORS设置。
See this thread for more details: HTTP OPTIONS request on Azure Websites fails due to CORS . 有关更多详细信息,请参见此线程: 由于CORS,Azure网站上的HTTP OPTIONS请求失败 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.