I am trying to get all Following IDs using Twitter API. Now on Load function am trying to alert the IDs array (FollowingArray ) which returned by GetFollowing.
I've test the value of array inside the function , but it looks OK. When i try to alert it appears as undefined.
I've test the value of array inside the function , but it looks OK. When i try to alert it appears as undefined.
Code:
function Load()
{
alert(GetFollowing("hatem"));
}
function GetFollowing(ScreenName)
{
var Following = $.ajax (
{
url: "https://api.twitter.com/1/following/ids.json?cursor=-1&screen_name=" + ScreenName,
dataType:"jsonp",
timeout:10000,
async:false
}
);
var FollowingArray = new Array();
Following.success
(
function(Follow)
{
i = 0;
while(Follow["ids"][i])
{
FollowingArray[i] = JSON.stringify(Follow["ids"][i]);
i++;
}
}
);
Following.fail
(
function()
{
alert("Error!")
}
);
Following.complete
(
function()
{
return FollowingArray;
}
);
}
Comment