$(document).ready(function(){
$("#find").click(function(){
$("#error").html('');
$("#obsh").html('Общие друзья:');
$.ajax({
url: 'https://api.vk.com/method/users.get',
data: {
user_ids: $('#id1').val()+','+$('#id2').val(),
v: '5.21',
},
type: 'GET',
dataType: 'jsonp',
success: function(r) {
b = $.cookie('access_token');
$.ajax({
url: 'https://api.vk.com/method/friends.getMutual',
data: {
source_uid: r.response[0].id,
target_uid: r.response[1].id,
access_token: b,
v: '3.0',
},
type: 'GET',
dataType: 'jsonp',
success: function(r) {
$("#obsh").html("Общие друзья: "+r.response.length);
for(i=0;i<=r.response.length;i++){
$.ajax({
url: "https://api.vk.com/method/users.get",
data: {
user_id:r.response[i],
fields: "photo_100",
v: "5.21",
},
type: "GET",
dataType: "jsonp",
success: function(r) {
$("#error").append("<div class='friend'><img width='100px' height='100px' src='"+r.response[0].photo_100+"'><div class='tx'><a href='http://vk.com/id"+r.response[0].id +"'>"+r.response[0].first_name+" "+r.response[0].last_name+"</a></div></div><hr>" )
},
});
}
},
});
},
});
});
});