0

Imagine you only have the chance to load a html file via a file URI scheme:

file://anypath/index.html

Inside fhe index.html you load a js file:

<script src="./index.js" rel="stylesheet"></script>

Inside the index.js you need a json file:

 ...
var xobj = new XMLHttpRequest();
    xobj.open('GET', 'index.json', true);
...

The Problem is you can not do a XMLHttpRequest via file:// URI scheme (Or?) ... Is there any way to get a external json file which is located at the same folder where the index.html is located?

melpomene
  • 84,125
  • 8
  • 85
  • 148
Christian Michael
  • 2,128
  • 1
  • 19
  • 27
  • *"Is there any way to get a external json file which is located at the same folder where the index.html is located?"* It should work just fine if you load `index.html` via a webserver. – Felix Kling Jun 11 '18 at 18:18
  • @FelixKling: Sure but "Imagine you only(!!!) have the chance to load a html file via a file URI scheme". What if you do not have the chance to put a webserver on the device ... ähm ... yes ... and you do not have the chance to connect to another webserver. "Imagine you only(!!!) have the chance to load a html file via a file URI scheme". No http-Request! – Christian Michael Jun 11 '18 at 18:31
  • Depends on the browser you are using then. E.g. https://stackoverflow.com/q/4819060/218196. This has nothing to do with JSON or JavaScript itself. – Felix Kling Jun 11 '18 at 18:38
  • Why don't you put everything in one file (index.html)? – melpomene Jun 11 '18 at 18:39
  • I have a index.html, index.js and a index.json. That is the starting position! I use a android tablet and have to call the file://index.html. The index.json is generated by another process. It is not possible to change the starting position! index.html, index.js and a index.json and no http requests. – Christian Michael Jun 11 '18 at 18:54

0 Answers0