I have a small function that downloads a JSON file from the server and displays its property on the website. Since my code is embedded in an old legacy system, I cannot use jQuery or any other infrastructure.
Loading information works fine, but when I try to set it to an element, the element is always null :
var element = document.getElementById("some_element_id"); element.innerHTML = output;
This only happens in Internet Explorer 9, all other browsers (and other versions of IE) work fine. The strangest thing: if I deactivate the browser cache, it works every time. I deactivate the cache with the Always update from server settings in IE Developer Tools. Any ideas how I can get this to work using JavaScript? We have many different IE installations, and this needs to be decided only by server-side actions (for example, changing the code, not the IE settings).
Edit
I checked all the known getElementById problems not working, for example. that JS is loaded after the DOM is ready, that the identifier exists only once, that there are no name and identifier conflicts, etc.
Edit 2
To provide a little more context that might matter: we download the JSON file from the server and use the following code to access it (now we are not perfect, but again, we use vanilla JS and must support IE6 up):
var jsondata = eval("(" + req.responseText + ")");
The browser cache seems to affect the loading of the JSON file. If it is downloaded directly from the server, the code seems to work. If it is loaded from the cache, problems arise.
source share