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

  • Home
  • SEARCH
  • 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 8876175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:08:49+00:00 2026-06-14T19:08:49+00:00

I am trying to get tweets from different zip codes.For doing this, I am

  • 0

I am trying to get tweets from different zip codes.For doing this, I am using latitude and longitude values for each zip code. So far I want to get 3 tweets for each zip code(I have 2 zip codes), but it is working only for one zip code.
Any suggestion will be appreciated. Thank you in advance!

Here is my code:

<!DOCTYPE HTML>
<html>
    <head>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
        <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>

        <script>
            var lat=[41.9716,42.0411];
            var lng=[-87.7026,-87.6900];
            $(document).ready(function() {
            for(var i=1; i<2; i++)
            {
                $.getJSON('http://search.twitter.com/search.json?q=business&geocode='+lat[i]+','+lng[i]+',5mi&lang=en&callback=?', function(data) {
                var data = data.results;
                var html = "";  
                for(var j=0; j<3;j++){
                    html += "<div style='width:600px;border:solid thin blue'><img src='"+data[j].profile_image_url+"'/><a href='http://twitter.com/" + data[j].from_user + "'>@"+ data[j].from_user + "</a>: " + data[j].text + "</div>";
            } 
            $('.content'+i).html(html);
            }); }
            });
    </script>
</head>

<body>
    <div class="content1"></div>
    <div class="content2"></div>
</body>

  • 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-06-14T19:08:50+00:00Added an answer on June 14, 2026 at 7:08 pm

    I found 2 problems with your code:

    1) If you want to iterate 2 times, your for function should be like this: for (var i = 0; i < 2; i++)

    2) You must have in consideration that the function that gets called in $.getJSON runs asynchronously, so when that function gets called the for will have already finished, therefore you can’t use the i value with that purpose inside that function.

    So, after correcting those 2 things in your code you should be able to get what you want. Try with something like this:

    <!DOCTYPE HTML>
    <html>
        <head>
            <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
            <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
    
            <script>
                var lat = [41.9716, 42.0411];
                var lng = [-87.7026, -87.6900];
                var count = 1;
                $(document).ready(function () {
                    for (var i = 0; i < 2; i++) {
                        $.getJSON('http://search.twitter.com/search.json?q=business&geocode=' + lat[i] + ',' + lng[i] + ',5mi&lang=en&callback=?', function (data) {                        
                            var data = data.results;
                            var html = "";
                            for (var j = 0; j < 3; j++) {
                                html += "<div style='width:600px;border:solid thin blue'><img src='" + data[j].profile_image_url + "'/><a href='http://twitter.com/" + data[j].from_user + "'>@" + data[j].from_user + "</a>: " + data[j].text + "</div>";
                            }
                            $('.content' + count++).html(html);
                        });
                    }
                });
        </script>
    </head>
    
    <body>
        <div class="content1"></div>
        <div class="content2"></div>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I keep getting this error, I'm trying to get tweets from twitter via
I am trying to get tweets from Twitter and send it through GTalk using
I am currently trying to send tweets from R, but I cannot get around
I'm trying to figure out how to get the most recent latitude and longitude
I'm trying to get the last 50 tweets using a certain hash tag, on
I'm trying to get the last tweet from the people I follow using the
I am trying to store the latitude and the longitude from an array where
I'm trying to get tweets to pull from a URL, which returns data in
I am using the Twitter GET search for retrieving tweets from a specified account,
I'm trying get the visible portion of UIImage from an UIImageView . UIImageView takes

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.