Changing the json as local file causing cross domain error
Changing the json as local file causing cross domain error
j_kathiresan
Posts: 14Questions: 4Answers: 0
Hi,
I downloaded the plunk - http://plnkr.co/edit/OMTCvaNbjHKVjNBQrXno?p=preview and when used a local json file it throws Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
i have used $http.get('100.json') instead of $http.get('https://cdn.rawgit.com/angular-ui/ui-grid.info/gh-pages/data/100.json')
Please let me know how to fix it.
Thanks.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Its a security measure, see this SO thread:
https://stackoverflow.com/questions/17947971/ajax-in-jquery-does-not-work-from-local-file
This is outside of Datatables.
Kevin
Hi Kevin,
Thanks again for your kind reply. I want the same table with export options but with static data i.e json will be in the same folder where the html file is. Could you please kindly fix it or let me know what needs to be changed to make it work?
Thanks a lot again.
This is not a Datatables issue. The issue is trying to open a file from the local filesystem. Most web browsers won't allow this by default. You may be able to change some settings.
The best option is to either put the file on a web server or run a web server locally and serve the file from that.
You can google search your error and find a lot of discussions.
Kevin
Imagine if they did allow it! Wow -
$.ajax( '/etc/passwd', ... )
!There is no way a browser should allow an Ajax request to a local file.
Allan
Thanks Allan and Kevin...I understand the problem...