Forum How do I...?

XMLHttpRequest for local files

alecov
Hello,

I read somewhere around here that `XMLHttpRequest()` does not work with `file:` URLs, but I believe it did in the past, because I have a set of presentation material from mid-2016 that definitely used `XMLHttpRequest()` to include/load other local files. These files do not compile anymore under latest Prince -- I receive `InvalidStateError` on the `send()` call.

Is there an alternative? I need to load certain other files (plain text, JSON, HTML documents, etc.) during processing to produce content using JavaScript.

Thanks.
alecov
Well, I tried some Prince versions from around the 2015-era and indeed the same error happens, so I presume I was running a local web server in order to compile the document. I can't really recall.

It perhaps makes sense to disallow `file:` on `XMLHttpRequest()` under grounds that most browsers CORS-block it as well, but since Prince can technically be used offline as an editing tool, I wonder if there will be a nice way to load a local file using JavaScript during compilation?