I probably already tired but...response.0 null or not object:
Code:
function file_get_contents_async( url ,callback) {
var req = null;
try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {
try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {
try { req = new XMLHttpRequest(); } catch(e) {}
}
}
if (req == null) throw new Error('XMLHttpRequest not supported');
req.open("GET",url,true);
req.onreadystatechange=function() {
if (req.readyState==4) {
var response = req.responseText;
callback(response);
}};
req.send(null);
}
function text1OnClick(Sender)
{
file_get_contents_async('http://api.vkontakte.ru/method/users.get?uids=1&fields=photo_200',function(response) {
//get the json.. lets say that is stored in a obj
//response is the downloaded string...
//BE WARNED THAT : if download fails no call is made
alert(response);
var obj = (response);
var uid = obj.response[0].uid;
var firstName = obj.response[0].first_name;
var lastName = obj.response[0].last_name;
var avatar = obj.response[0].photo_200;
alert(lastName);
});
}
Definitions not JSON :
Code:
function file_get_contents_async( url ,callback) {
var req = null;
try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {
try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {
try { req = new XMLHttpRequest(); } catch(e) {}
}
}
if (req == null) throw new Error('XMLHttpRequest not supported');
req.open("GET",url,true);
req.onreadystatechange=function() {
if (req.readyState==4) {
var response = req.responseText;
callback(response);
}};
req.send(null);
}
function text1OnClick(Sender)
{
file_get_contents_async('http://api.vkontakte.ru/method/users.get?uids=1&fields=photo_200',function(response) {
//get the json.. lets say that is stored in a obj
//response is the downloaded string...
//BE WARNED THAT : if download fails no call is made
alert(response);
var obj = JSON.parse(response);
var uid = obj.response[0].uid;
var firstName = obj.response[0].first_name;
var lastName = obj.response[0].last_name;
var avatar = obj.response[0].photo_200;
alert(lastName);
});
}