Loading JSON data without AJAX

In my small JS web application, I use some JSON data.

The data is located on the server in a separate static .json file.

My application, being small, does not use any frameworks, not even jQuery. And I don't 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 emulating JSONP or including data in existing JS sources.)

This is normal if it will only work in modern browsers.

+7
json javascript
source share
1 answer

There are no reasonable ways.

You may be able to display it in an iframe and read it from there, but (since you have to solve synchronization problems), which is at least as complicated as using XMLHttpRequest, and risks that browsers that choose to load JSON instead of rendering.

Use XMLHttpRequest. It's not hard.

+7
source share

All Articles