Reputation: 41393
In my small JS web-application, I use some JSON data.
The data is on server in a separate static .json
file.
My application, being small, does not use any frameworks, not even jQuery. And I do not want to mess with XMLHTTPRequest
myself.
Is there a way to load my JSON data without AJAX? (And without renaming the file to .js
and imitating JSONP
or including the data in existing JS sources.)
It is OK if it will work only in modern browsers.
Upvotes: 9
Views: 5510
Reputation: 943510
There aren't any sensible ways.
You might be able to display it in an iframe and read it from there, but (since you will have to deal with timing issues) that is at least as complicated as using XMLHttpRequest, and risks browsers deciding that JSON should be downloaded instead of rendered.
Use XMLHttpRequest. It isn't complicated.
Upvotes: 7