0

I develop a javascript application which display data from xml with charts and lists. For now I put some sample files onto the server's directory that I load with :

$.ajax({ type: 'GET', url: 'data/default.xml', dataType: 'xml', ...})

The Xml files can be very heavy so when one of them is loaded I put the data in an IndexedDB.

In a second time I would like to let the visitor loads its own xml file by giving the filepath of the xml (f.i. : /home/user/sample.xml). I do not want to upload this file onto the server because I do not need it and it could be too big. But I do want to load those data in the IndexedDB and let the app displays data without any call to the server.

I do not know if browsers could work this way? If they could, how can I do such a trick?

2
  • When you say indexed DB, do you have something specific in mind? Commented Dec 13, 2012 at 13:21
  • Yes, very specific as I mean IndexedDB : developer.mozilla.org/en-US/docs/IndexedDB Commented Dec 13, 2012 at 13:38

1 Answer 1

1

You can't use Ajax to get data from a file on the client system, but in sufficiently modern browsers you can use the File API. MDN has a guide to the File API that is friendlier then the specification.

Sign up to request clarification or add additional context in comments.

1 Comment

I use "sufficiently modern browsers" as my application uses indexeddb which needs sufficiently modern browsers. That a great answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.