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 8062155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:34:23+00:00 2026-06-05T10:34:23+00:00

I need some help with my code (clearly). So far I’m able to get

  • 0

I need some help with my code (clearly). So far I’m able to get the json data that I want but I can’t seem to store it in a global array. My goal is to get data.count and data.url in an array like this:

var myHelpfulVariable = [
    // e.g. [data.count, '{label:' + data.url + '}']
    [3856, {label:'http://www.google.com/'}],
    [1897, {label:'http://www.yahoo.com/'}],
    [3870, {label:'http://www.microsoft.com/'}]
]

I’ve tried a few different methods using the push function all to no avail. Below is the code that gets the data but it doesn’t attempt to put it into an array.

Could someone please help? An explanation of why it works would also be helpful. Thanks in advance!

<script src="jquery.min.js"></script>
<script>
$(document).ready(function(){

    var getData = [
        'http://urls.api.twitter.com/1/urls/count.json?url=http://www.google.com&callback=?',
        'http://urls.api.twitter.com/1/urls/count.json?url=http://www.yahoo.com/&callback=?',
        'http://urls.api.twitter.com/1/urls/count.json?url=http://www.microsoft.com&callback=?'
    ];

    $.each(getData, function(i,getValue) {

        var urlForGetJSONfunction = "'" + getValue + "'"    

        $.getJSON(getValue,  function(data) {
            $('<div></div>').append('<strong>' + data.count + '</strong>' + ' retweets for: ' + '<a href="' + data.url + '">' + data.url + '</a>').appendTo('body')


            })//ends getJSON

    })//ends each loop
});
</script>
  • 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-05T10:34:25+00:00Added an answer on June 5, 2026 at 10:34 am

    array.push( obj ) does exactly what you would expect, adds the object to the end of the array. Arrays elements in JS don’t have to be of the same type, so you can simply push your data as you get it as follows:

    var myHelpfulVariable=[];
    
    $.each(getData, function(i,getValue) {
    
        var urlForGetJSONfunction = "'" + getValue + "'";  
    
        $.getJSON(getValue,  function(data) {
            $('<div></div>').append('<strong>' + data.count + '</strong>' + ' retweets for: ' + '<a href="' + data.url + '">' + data.url + '</a>').appendTo('body');
    
            var pair = [];
            pair.push(data.count);
            pair.push({'label':data.url});
    
            myHelpfulVariable.push(pair);
    
        });//ends getJSON
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help with my code. I have an UIAlert that pops up
Hey guys! I need some help writing a code that creates an array in
I need some help with some advanced file include code.. I googled around, but
I need some help understanding this bit of code pre { white-space: pre; white-space:
I need some help with some PHP and MySQL code. At the moment I
I got some code off the Internet and now I just need help to
Need some help assigning a mouseover event to display some icons that start out
Im new to obj-c and need some help with this code NSDateFormatter *dateFormatter =
I need some help with the code below. What I'm trying to do is
I am a Java rookie and need some help with my code. I am

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.