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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:15:53+00:00 2026-05-26T18:15:53+00:00

Hey all I’ve just been fooling around with the HTML5 Database API and I’m

  • 0

Hey all I’ve just been fooling around with the HTML5 Database API and I’m having trouble return the result from a function. Here is what I have.

var list = GetScenarios();

GetScenarios: function()
{

var scenarios;

// get all the scenarios
conn.transaction(function(_t) {

_t.executeSql('SELECT * FROM scenarios', [], function(_tr, _result) {

        scenarios = _result.rows;

    });
});

return scenarios;

}

I manage to get the rows from the db but the rows wont assign to the variable scenarios. I know its a scope thing but I can’t think how to return the result from the GetScenatios function.

When I log _result.rows I have the data there but scenario is always undefined;

Any thoughts?

Here is how my js file is setup.

window.MyExtension = (function() 
{

    return ({

    OtherMethod: function() {   


        var list = window.MyExtension.GetScenarios();

    },

    GetScenarios: function() {

         ...see above

    }

}());
  • 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-26T18:15:54+00:00Added an answer on May 26, 2026 at 6:15 pm

    It looks like you are trying to return code from an asynchronous request as though it were synchronous. You need to add a callback parameter to GetScenarios():

    function GetScenarios(callback) {
        conn.transaction(function(_t) {
            _t.executeSql('...', [], function(_tr, _result) {
                callback(_result.rows);
            });
        });
    }
    

    And change your calling code from:

    var list = GetScenarios();
    // do something with list
    

    To, this:

    GetScenarios(function (list) {
        // do something with list
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all, I'm having a little trouble packing a numpy.float32 using the struct.pack function.
Hey all, I'm having some trouble setting up my grails application. Running the app
Hey all. We're sending quite a few emails (around 23k) using IIS6 SMTP service
Hey all I want to reseed my IDENTITY COLUMN values starting from 1 I
Hey all. I've been been trying to figure this out for a while now.
Hey all, just wondering what the best way to add this capability was. I
Hey all. To be honest, I don't prefer MS Access as a relational database
Hey all, just a quick question (should be an easy fix I think). In
Hey all. Ive got a headache trying to get my head around this. I
hey all, I'm very confused here, i've been trying to figure this one out.

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.