mercredi 2 septembre 2015

CORS, SQLite and JavaScript. Any way to access the actual database without a local server?

I just discovered the wonderful thing that SQLite is, and I'm trying to get it to work on a local HTML file without a server, just plain JavaScript.

The SQLite wiki states that the local database be 'get' via XMLHttpRequest

var xhr = new XMLHttpRequest();
xhr.open('GET', '/path/to/database.sqlite', true);

But I can't because it's a cross origin requests. I had similar issues in the bast trying to read CSV files, and I solved it by using a file input and then passing the file forward to be parsed.

I tried doing the same thing, instead of passing /path/to/database.sqlite just passing the actual file. But it doesn't work.

Is there anyway to make this work without a local server and without messing with the security rules of the browser?

Aucun commentaire:

Enregistrer un commentaire