Re: Не доступен объект из вне. JS
Добавлено: 16 июн 2013, 23:29
ща попробую наваять)
Код: Выделить всё
$.post('php/results.php', {viewer_id: flashVars['viewer_id'], auth_key: flashVars['auth_key'], operation: 'getWinners'}, function(data) { get_users($.parseJSON(data), 0);}); function get_users(data, i){ if(data.response.length <= i) return; //Если data.response.length <= i то завершаем работу ибо массив кончилсо uids = data.response[i].uids; VK.api('users.get', {uids: uids, fields: 'photo_50'}, function(vked) { alert(data.response[i].number); //Должно работать /*** другой наш код ***/ //Ну и вызываем саму себя увеличив индекс get_users(data, ++i); });}
Код: Выделить всё
$.post('php/results.php', {viewer_id: flashVars['viewer_id'], auth_key: flashVars['auth_key'], operation: 'getWinners'}, function(data) { get_users($.parseJSON(data), 0);}); function get_users(data, i){ if(data.response.length <= i) return; uids = data.response[i].uids; VK.api('users.get', {uids: uids, fields: 'photo_50'}, function(vked) { for(j=0; j<vked.response.length; j++) { alert(vked.response[j].photo_50); } get_users(data, ++i); });}