Wednesday, 20 March 2019

jquery - How to access json file via chrome

I have a local json file in my web directory and want to access it.
I currently use $.getJSON() from jquery and it works fine with all browsers but chrome.



How can I access this file via chrome?




Code:







Edit: totaly forgot to paste the chrome console error here:




Access to XMLHttpRequest at
'file:///C:/Users/Sirzento/Desktop/website/JsonData.json' from origin
'null' has been blocked by CORS policy: Cross origin requests are only
supported for protocol schemes: http, data, chrome, chrome-extension,
https.



No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print ...