I have a json file stored on a local desktop. When I try to access it I keep getting this error.
CORS策略已阻止从源“空”访问“ file:/// C:/Users/User/Desktop/basicblog/test.json”处的XMLHttpRequest:仅协议方案支持跨源请求: http,数据,chrome,chrome扩展名,https。
This is the code that has been used in order to access such folder.
$.getJSON("test.json", function(json){
console.log(json);
});
{
"articles": [
{
"id": "111",
"title": "How do like them apples?",
"text": "Lorem ipsum elit ante aliquam blandit nulla gravida, elementum sollicitudin ipsum litora rhoncus urna, nec in pulvinar quam libero dictumst. Duis hac augue auctor sed proin senectus ante purus est, condimentum mattis nostra non porttitor sit nibh ornare etiam quisque eros ultricies eget taciti inceptos etiam ornare feugiat pretium. Varius ullamcorper imperdiet tortor quisque odio ullamcorper pulvinar, tortor semper primis consequat libero erat, adipiscing mi donec semper duis magna.",
"author": "simon",
"category": "mobile",
"comments": [
{
"id": "1",
"author": "shaun",
"text": "Lorem ipsum varius senectus nostra lectus nunc sollicitudin."
},
{
"id": "2",
"author": "william",
"text": "aliquam blandit nulla gravida"
}
]
},
]
}