Why isn't this AJAX request waiting? -


i try make ajax request jquery flickr, single images url , return src process further, jquery doesn't wait, returns default declaration of "":

function getflickr(url){ var src = ""; var settings = $.extend({      url : url,     key : '61328c74e544a789b356a36aec03acfe',     secret : 'f119e504140f0964'     }),     id,     method = 'flickr.photos.getinfo',     format = 'json', id = settings.url.match(/\/photos\/(.*)/)[1].split('/')[1]; $.ajax({     type: 'get',     url: 'http://www.flickr.com/services/rest/?method='+method+'&format='+format+'&api_key='+settings.key,      async: false,     datatype: 'json',     data: {'photo_id':id},     jsonpcallback: 'jsonflickrapi',     success: function(data){        src = 'http://farm'+data.photo.farm+'.static.flickr.com/'+data.photo.server+'/'+id+'_'+data.photo.secret+'.jpg';          alert(src);               //$(this).append('<img src="http://farm'+data.photo.farm+'.static.flickr.com/'+data.photo.server+'/'+id+'_'+data.photo.secret+'.jpg">');      } }); return src; } 

and call functions this:

lnk = getflickr(url);    

but "" response, on code debugging first code break wrong response, not inside ajax success callback, doing wrong?

thx help


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -