Hello all
trying to pick up some jSon.
i have a reg index.php file.
I have this js that is called in the index file
var request;
if(window.XMLHttpRequest){
request=new XMLHttpRequest();
}else{
request=new ActiveXObject("Microsoft.XMLHTTP");
}
request.open('GET', '/js/data.json');
request.onreadystatehchange = function(){
if((request.status=200) &&
(request.readyState===4)){
var output =" ";
for(var i =0; i<=info.link.length-1;i++){
for(key in info.links[i]){
if(info.links[i].hasOwnProperty(key)){
output += '<li>' + '<a href ="' +info.links[key] + '">' + key + '</a>' + '</li>';
}
}
}
var update = document.getElementById('links');
update.innerHTML = output;
}
}
request.send();
and this in the data.json file
var info={
"full_name": "jane doe",
"title": "web author",
"links":[
{"blog":"http://marketthis.com"},
{"fb":"http://marketthis1.com"},
{"yt":"http://marketthis2.com"},
{"web":"http://marketthis3.com"},
{"twitt":"http://marketthis4.com"}
]
};
And lastly this bit in the index.php
<ul id="links" class="links">
</ul>
am doing this on a localhost. in chrome i get an error, > GET http://localhost/js/data.json 404 (Not Found)
but i don’t get a an error in FF. Although it doesn’t display the data there either.
So was hoping you could tell me what i am doing wrong.
thx
D