Sam Mason
Sam Mason

Reputation: 1037

Is it possible to use xhr for local files?

I can't find any recent answers to this, is it possible to load up a local file using AJAX request. So in my site I have a file called data.json on my web server is it possible to request the date from my Js file using a relative path rather than using its web accessible url and therefore incurring a speed cost.

Upvotes: 1

Views: 2321

Answers (1)

Kijewski
Kijewski

Reputation: 26022

A site with an origin http://…, https://…, … cannot access content via file:///…. Otherwise nothing could stop any arbitrary website from stealing your local data. Probably the buzzword you are looking for is localStorage.

See also: noscript's ABE, a popular addon that makes the separation between local and remote content even stricter.

See also: “Firefox exploit found in the wild”, when the separation fails.

Upvotes: 3

Related Questions