Retrieve JSON with stackoverflow API
Posted
by
ArtWorkAD
on Stack Overflow
See other posts from Stack Overflow
or by ArtWorkAD
Published on 2010-12-29T11:31:06Z
Indexed on
2010/12/29
11:54 UTC
Read the original article
Hit count: 393
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?
© Stack Overflow or respective owner