11
rated 0 times
[
17]
[
6]
/ answers: 1 / hits: 38126
/ 12 Years ago, thu, july 19, 2012, 12:00:00
How do I load an object into javascript if it is available in a json file?
I have the following script in my html:
<script src='scene.json'></script>
<script>
var x = scene.x;
</script>
And this is the file scene.json, located in the same folder:
{scene: {
x: 0,
y: 0,
w: 11000,
h: 3500,
}}
But the json file is not loaded properly (unexpected token ':') and the scene.x reference is also probably not the way it should be done. Is it possible to refer to the data directly? Or does it need to be loaded by some http request?
More From » json