我试图使用下面的脚本在我的html文件中访问此文件,但它一直给我错误:
$.getJSON('https://(url of the file uploaded to file server is here)/data.json', function(data){
//code goes here
})
当我在浏览器上加载文件时文件正在工作但是当我打开html文件时,我在控制台中收到此错误:请求的资源上没有“Access-Control-Allow-Origin”标头。因此不允许原点'null'访问。 我错过了什么? 这是我的json文件:
[
{
"name":"United Kingdom",
"countryCode":"GB",
"urlCode":"en-gb",
"standardPrice":"30",
"standardFreeOver":"x",
"standardTimes":"x",
"expressPrice":"x",
"expressTimes":"x",
"collectionPrice":"x",
"collectionFreeOver":"x",
"collectionTimes":"x",
"collectionPoints":"x",
"imgName": "uk"
},{
"name":"Germany",
"countryCode":"DE",
"urlCode":"de-de",
"standardPrice":"22",
"standardFreeOver":"0",
"standardTimes":"x",
"expressPrice":"x",
"expressTimes":"x",
"collectionPrice":"x",
"collectionFreeOver":"x",
"collectionTimes":"x",
"collectionPoints":"x",
"imgName": "de"
}
]