Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3396814
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:27:09+00:00 2026-05-18T04:27:09+00:00

I’m looping through JSONP with JQuery in order to get a list of usernames.

  • 0

I’m looping through JSONP with JQuery in order to get a list of usernames. I then want to send each username through the Twitter API to return a series of things (number of followers, etc). Then display it all together. This is part of a much larger “dashboard” based on political candidates. Because the code I’ve written is pretty

I’m able to import and loop through that first JSONP without a problem.

The problem comes when I toss in the Twitter stuff: the resulting code does actually load up all of the users’ info, but does it all at once, looping through and replacing each ID until it’s reached the bottom of the list. This is confusing to me because it’s happening within the original .each loop.

Here’s a simplified version of the code:

var URL = "biglist.json"

$.getJSON(yqlURL, function(data) {

$.each(data.query.results.row, function() {

var name = this.col0
var twitter = this.col5

var li = $('<li>').html('<li>'+name+'<li>Twitter ID: @'+twitter+'<span class="tweetdisplay"></span>');

var followers="http://api.twitter.com/1/users/show.json?screen_name="+twitter+"&callback=?"

$.getJSON(followers, function(tweets) {

$('.tweetdisplay').html('<li>twitter followers: ' +tweets.followers_count);

});

$('#result ul').append(li);

});
});

I am pretty sure I am missing something really straightforward, but I am most definitely missing it. Any help would be much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T04:27:10+00:00Added an answer on May 18, 2026 at 4:27 am

    I’m guessing the problem you’re having is because the inner $.getJSON() call is asynchronous. It will fire off all the requests straight away without waiting for a response. Then, whenever it gets a reply from the server it will call your function(tweets) {... code. There is no guarantee that the responses from the server will come back in the same order that you sent them, especially since your loop will fire off all the requests pretty much simultaneously.

    In order to make it work the way you want, you’ll need to add in some kind of check to see if the server has responded to all your $.getJSON(followers ... requests, and then append each one to the <ul> list. Leave me a comment if you need help with that.


    Update (2010-11-18): Turns out I was wrong about the issues you were having. I think you may have got your classes confused with IDs. Here’s a modified version of your code that works:

    $.each(data.query.results.row, function() {
        var name = this.col0;
        var twitter = this.col5;
    
        var li = $('<li>').html('<ul><li>'+name+'</li>'
                   + '<li>Twitter ID: @' + twitter
                   + ' <span class="tweetdisplay"'
                   + 'id="' + twitter + '"></span></li></ul>'
        );
        $('#result>ul').append(li);
    
        var followers="http://api.twitter.com/1/users/show.json?screen_name="+twitter+"&callback=?"
        $.getJSON(followers, function(tweets) {
            $('#'+twitter).html('twitter followers: ' +tweets.followers_count);
        });
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want to show the soap response to UIWebview.. my soap response is, <p><img

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.