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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:43:31+00:00 2026-06-04T04:43:31+00:00

I am having trouble with two functions because they rely on chaining Async Tasks.

  • 0

I am having trouble with two functions because they rely on chaining Async Tasks. The clearAll is a click event which should empty the database then reload the page. Clear is a function from the database module (database.clear).

I would like to use JQuery Promises/Deffered if they are appropriate but I cant quite grasp them for this use case.

I have re-written the code following @Larry K’s answer

    clearAll: function()
    {
        var refresh = function()
        {
            localStorage.clear();  
            sessionStorage.clear();
            window.location.href = window.location.pathname;
            console.log("feeling refreshed");
        };

        database.open();

                    //This is what I'd like to be able to do
                    //With Jquery or callbacks
        $.when(database.clear()).then(refresh);

    },

clear: function (callback, errorCallback)
{
    var sql = "SELECT name FROM sqlite_master WHERE type='table' AND name != ?",
    args = ["__WebKitDatabaseInfoTable__"];

    var dbTableNamesResult = function (tx, result)
    {
       var dropSql  = "";

       for (var i = 0; i < result.rows.length; i++)
       {
        dropSql = "DROP TABLE IF EXISTS " + result.rows.item(i).name + "; ";
        execute(dropSql);
       }
    };

    execute(sql, args, dbTableNamesResult);
},
  • 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-04T04:43:32+00:00Added an answer on June 4, 2026 at 4:43 am

    Having attempted to implement jQuery deferred myself the answer I was looking for was provided by zerkms’s answer to How can I write this as a jQuery deffered function

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

Sidebar

Related Questions

I am having some trouble determining if two line segments are collinear because of
I'm having trouble grasping generic methods. I have two classes that are generated (they
Currently i'm having trouble using two functions in my -(void)viewDidLoad , both of these
I'm having trouble generating two independent random sequences using the rand and srand functions.
I'm having some trouble deciding how two classes should interact and the problem I'm
I'm new to linq and having trouble writing two simple queries. For some reason,
I am having trouble deciding between two possible design choices. I have a web
Im having some trouble with joining two tables. This is what my two tables
I am having some trouble with aligning two div boxes next to each other;.
I'm having trouble with a simple radio set of two radio buttons (I don't

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.