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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:43:56+00:00 2026-06-11T03:43:56+00:00

My Code is in phonegap application. While executing a SELECT SQL statement, I am

  • 0

My Code is in phonegap application. While executing a SELECT SQL statement, I am experiencing difficulties to pass the results to parent function’s variable. The code is represented below:

function db_data(query) {
var result_out;
db.transaction(function (tx) {
    tx.executeSql(query, [], function (tx, results) {
        console.log("RETURNED SUCCESSFUL RESULTS"); // SUCCESSFULLY EXECUTING HERE.
        result_out = results.rows;
    }, function (){
        console.log("Error on executing sql");
        result_out = false;
    }); 
});
console.log(result_out); // NOTHING LOGGING HERE.
return result_out;
}

This function is to pass common SELECT statements. The function is not returning any thing and the returning object is successfully logged only within the SQL execution function.

  • 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-11T03:43:58+00:00Added an answer on June 11, 2026 at 3:43 am

    The operation is asynchronous. The operation inside db.transaction may take effect in a later time. By the time you logged the result, it isn’t there yet.

    If you want to execute something after getting a value for result_out, you need to put it inside the callbacks:

    function db_data(query,callback) {
        var result_out;
        db.transaction(function (tx) {
            tx.executeSql(query, [], function (tx, results) {
                console.log("RETURNED SUCCESSFUL RESULTS"); // SUCCESSFULLY EXECUTING HERE.
                callback.call(this,results.rows);
            }, function (){
                console.log("Error on executing sql");
                callback.call(this,false);
            }); 
        });
    }
    

    when using db_data, instead of

    var result = db_data('your query');
    //do something with result
    

    do this instead

    db_data('your query',function(result){
       //do something with result here
       //result will either be a false or the result
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

currently i using this code in phonegap application var xmlhttp = new XMLHttpRequest(); xmlhttp.open(GET,http://192.168.1.19:8080/searchMobile?categoryRequest=true,
I want to integrate a php code into my application phoneGap(HTML). So, I tried
i just join phonegap, i want a built test application. i write some code
This is my code //This is an event that fires when a PhoneGap application
I want to call web services in phonegap application. I am using demo code
I have developed android phonegap application using javascript. I am having one parent div
I would need help with the logic behind one code. in my phonegap application
right now i have this code using phonegap and jquerymobile $( '#user_detail' ).live( 'pageinit',function(event)
I've tried the PhoneGap code at but it doesnt work. The click on menubutton
i have some code using jquery mobile + phonegap and run it on my

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.