A
amcallis01
I'm trying to load JSON data using this (well published...) code in my
html head tag:
<script type="text/javascript">
var e = document.createElement('script');
e.setAttribute("type", "text/javascript");
e.setAttribute("src", "jsonData.txt");
document.getElementsByTagName("head")[0].appendChild(e);
</script>
The contents of jsonData.txt looks like:
var json;
json=[{"id":"20226 Pioneer Blvd, Cerritos, CA
","lat":"33.846611","lng":"-118.081933"},{"id":"7565 Carson Blvd, Long
Beach, CA ","lat":"33.825825","lng":"-118.085297"}];
When I try to access the variable "json", IE6 and IE7 tell me that
json is undefined. However "json" is defined when using FF2.
Mysteriously, if I put "alert('hi');" just before my </script> tag,
"json" *does* get defined in IE6&7. Not sure why that would be.
Any suggestions on how to load this JSON data across these 3
browsers? I would prefer to stick with this general method (vs. AJAX)
if possible.
html head tag:
<script type="text/javascript">
var e = document.createElement('script');
e.setAttribute("type", "text/javascript");
e.setAttribute("src", "jsonData.txt");
document.getElementsByTagName("head")[0].appendChild(e);
</script>
The contents of jsonData.txt looks like:
var json;
json=[{"id":"20226 Pioneer Blvd, Cerritos, CA
","lat":"33.846611","lng":"-118.081933"},{"id":"7565 Carson Blvd, Long
Beach, CA ","lat":"33.825825","lng":"-118.085297"}];
When I try to access the variable "json", IE6 and IE7 tell me that
json is undefined. However "json" is defined when using FF2.
Mysteriously, if I put "alert('hi');" just before my </script> tag,
"json" *does* get defined in IE6&7. Not sure why that would be.
Any suggestions on how to load this JSON data across these 3
browsers? I would prefer to stick with this general method (vs. AJAX)
if possible.