I have a small web app that consumes data from an XML file to display. It's basically just 3 files:
app.html
logic.js
data.xml
The javascript file loads the XML data and processes it:
$.get('data.xml', {}, processResult);
I would like this little app to be able to run when launched locally with the file:// protocol. However I am getting the following error:
Access to XMLHttpRequest at 'file:///C:/.../data.xml' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.
Basically I need a way for javascript to request another file in the same directory. Is this possible? I can make any changes to the JS or HTML files but the XML file comes from a vendor and it would be a pain to modify it each time (e.g. to wrap it in JSON or JSONP).
<script src="logic.js"></script>. Obviously I understand that you don't want an http site to poke around on the file system but that is not really the case here, the browser is already opening local files.file://protocol.var xml = '<?xml>...';and then load it via<script src="data.xml.js"></script>. It's dumb but it works overfile://.