Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load JSON data without AJAX

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.

like image 975
Alexander Gladysh Avatar asked Sep 28 '13 21:09

Alexander Gladysh


1 Answers

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.

like image 116
Quentin Avatar answered Oct 13 '22 10:10

Quentin