javascript - Using two $.get in one. Trying to use as a variable -


this question has answer here:

this code

$(function () {    $.get('/viewonline', function (data) {     data = $(data);     var members = data.find('.userdata');    (var j = 0; j < members.length; j++) {      var membername = $(members[j]).find('.username').text();      var memberurl = $(members[j]).find('.username').attr('href');      var memberava = $.get(memberurl, function(data) {                     data = $(data);                     data.find('#profile-advanced-right img:eq[0]').attr('src');        });   $('.user_info_on').append('<div class="on_name"><a href="' + memberurl + '" title="'+ membername +'"><img src="' + memberava + '"/></a></div>');        }     }, 'html'); }); 

as can see in var memberava area use $.get function. trying use users url pass function place together. though [object object] figured. possible use 2 $.get together? if not best option grab image src need?

try commenting callback- this?

  $(function () {    $.get('/viewonline', function (data) {     data = $(data);     var members = data.find('.userdata');    (var j = 0; j < members.length; j++) {      var membername = $(members[j]).find('.username').text();      var memberurl = $(members[j]).find('.username').attr('href');      var memberava = $.get(memberurl, function(image) {                     image = $(image);                     image.find('#profile-advanced-right img:eq[0]').attr('src');        });   $('.user_info_on').append('<div class="on_name"><a href="' + memberurl + '" title="'+ membername +'"><img src="' + memberava + '"/></a></div>');        }     }, 'html'); }); 

i think need create global variable , when second ajax request succeeds may set value of global variable , can use anywhere.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -