Retrieve JSON with stackoverflow API
- by ArtWorkAD
Hi,
I want to retrieve the information of my stackoverflow profile as JSON using the api. So I use this link http:/api.stackoverflow.com/1.0/users/401025/.
But when I make the request I get a file containing the JSON data. How do I deal with that file using javascript?
Here is my code (http://jsfiddle.net/hJhfU/2/):
<html>
<head>
<script>
var req;
getReputation();
function getReputation(){
req = new XMLHttpRequest();
req.open('GET', 'http://api.stackoverflow.com/1.0/users/401025/');
req.onreadystatechange = processUser;
req.send();
}
function processUser(){
var res = JSON.parse(req.responseText);
alert('test');
}
</script>
</head>
The alert is never fired and req.responseText seems to be empty. Any ideas?