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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:52:44+00:00 2026-06-10T14:52:44+00:00

I am building a mobile app using phonegap , jQuery and jQuery mobile .

  • 0

I am building a mobile app using phonegap, jQuery and jQuery mobile. I want to use SqLite database in my app for storing some user information. (I can’t use local storage i want to do search/sort operations on the data)

This is the code I am working on to get this done,

function getAccountInformation(){
    var accounts = {};
    db.transaction(function(transaction) {
        transaction.executeSql('SELECT * FROM account;', [], 
            function(transaction, result) { 
                if (result != null && result.rows != null) { 
                    for (var i = 0; i < result.rows.length; i++) {
                        var item={};
                        var row = result.rows.item(i); 
                        for(var prop in row){
                            item[prop]=row[prop]
                        }
                        accounts[i]=item;
                    }
                }
            },errorHandler
        );
    },errorHandler,nullHandler);
    console.log(JSON.stringify(accounts));
}

If I put this console.log(JSON.stringify(accounts)); after the end } of the for loop it shows proper output.

But if I put it where it is right now the {} is printed as an output.

How can I make getAccountInformation() function return that accounts object to my other function? Where I will use jQuery to render the output.

What I want to do is return this accounts object simply by wrting
return accounts;

  • 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-10T14:52:46+00:00Added an answer on June 10, 2026 at 2:52 pm

    Because the SqLite functions are asynchronous you cannot just return the value.

    I would make the getAccountInformation receiving a callback as below:

    function getAccountInformation(callbackfn)
    {
        db.transaction(function(transaction),
            .....,
            function (transaction, result)
            {
                if (result != null)
                {
                   callbackfn(result);
                }
            });
    }
    

    In such way you will get your function called when the db request executed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building an iPhone app using jQuery Mobile, jQuery 1.7.2, and PhoneGap trying
I am building a mobile app using jquery mobile and phonegap for both android
I'm building my first mobile app using PhoneGap and jQuery Mobile, and I've run
I am building an app using Phonegap and jQuery mobile... On my index.html page,
I'm building a simple content app using PhoneGap + jquery mobile. My AdMob banner
I am building a PhoneGap app using jQuery Mobile. My JSONP cross domain communication
I am building a mobile app using Jquery mobile. It´s a multi-page app all
I'm building a mobile app using HTML, CSS, Javascript and jQuery. Is there a
I am currently building a game in phonegap using jQuery Mobile frame work. What
I'm building a web app using jquery mobile that will have lots of images

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.