Amromtm Amromtm - 4 months ago 18
JSON Question

parse data from JSON url using javascript

I want to make an ajax request and parse the JSON response.
I have tried to do so with this code but with no luck

var url = 'http://api.steampowered.com/ISteamUser \
/ResolveVanityURL/v0001/?key=private_key&vanityurl=zacktm'
$.getJSON(url, function(data) {
alert(data);
});


The response that I get is:

{
"response": {
"steamid": "76561198181548891",
"success": 1
}
}


the output I want:
76561198181548891

Answer

A temporary solution for development would be to use crossorigin.me

Code would be:

var url = 'http://crossorigin.me/http://api.steampowered.com/ISteamUser/ResolveVanityURL/v0001/?key=0E385DC97C8423D8DD9CD11944187F38&vanityurl=zacktm'
$.getJSON(url, function(data) {
    alert(data.response.steamid);
});
Comments