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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:12:50+00:00 2026-05-25T12:12:50+00:00

(I think that this is a callback issue, but I’m not completely sure) I

  • 0

(I think that this is a callback issue, but I’m not completely sure)

I have a function that wants to retrieve data from all tabs. It looks like:

function retrieveData(callback) {
    getAllTabs(function(openedTabs) {
        for(var t=0; t<openedTabs.length; t++) {
            //get data from this tab
        }
    });
    //log(look at updated data)
}

function getAllTabs(callback) {
    if(callback) {
        chrome.windows.getAll({populate: true}, function(windows) { 
            //get tabs from windows; callback(tabs)
        });
    }
}

My problem is not that I don’t get the data from the tabs. That works fine. It’s that if I call retrieveData, the functions occur in an order s.t. I don’t get the data until after I’ve already left function retrieveData, i.e. if I look at my data right where that log statement is in getAllTabs, there are no updates.
How do I fix this so that the data is there in a sequential order?

  • 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-25T12:12:51+00:00Added an answer on May 25, 2026 at 12:12 pm

    I’m not sure I quite understand the phrasing of the problem, but I think the problem is that you’re dealing with asynchronous requests not synchronous requests. When you call chrome.windows.getAll, the function does not return all the tabs right away. Instead, you’re saying to Google Chrome: “I want all the tabs, but don’t give it too me right away. When you have all the tabs, run this callback function”.

    If you want to run log(look at updated data) sequentially after getting all the tabs, you should put it inside the callback function you pass to getAllTabs

    function retrieveData(callback) {
        getAllTabs(function(openedTabs) {
            for(var t=0; t<openedTabs.length; t++) {
                //get data from this tab
            }
            //log(look at updated data)
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't think that this is specific to a language or framework, but I
I don't think that this could be done in C#, but posting this just
I don't think that this is doable, but wanted to throw it out to
Searching here I found that this question was already asked , but I think
This is for an iPhone App, but I don't think that really matters. I
I have a LRESULT CALLBACK function in a header file(hook.h) that I both forward
I have the notion that this is very easy and over-documented, but I have
I think that this problem can be sorted using reflection (a technology which I'm
I'm familiar with some mnemonic/memorization techniques for about a year. I think that this
sed 's/^\(\h*\)\(.*\)$/\1<!-- \2 -->/' web.xml I think that this should take this xml: <a>

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.