I have a folder structure like this.
- [ site ]
- [ js ]
- [ json ]
- hints.json
- page.html
Now when I launch my page.html I have a button that when I click is going to load my hints.json file. Here is my script for loading the json.
$(function(){
var jsonURL = "json/hints.json";
var butt = $('.button .hints li');
butt.find('a').click(function(evt){
$.getJSON(jsonURL, function(value){
console.log(" title = ", value.intro[0].title);
});
});
});
Json file structure.
{
"intro": [
{"title": "title text", "copy": "copy text1"},
{"title": "title text", "copy": "copy text1"}
],
"active":[
{"title": "Title text for page active", "copy": "copy text"}
]
}
Can anyone tell me why this would not work.
Update: This is been tested locally not from a server.
Here is a jsfiddle example even though I'm trying to get it to work locally. http://jsfiddle.net/r3bPC/1/
quest.jsonbut actually you are loadinghints.json... just in case ...