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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:43:16+00:00 2026-06-05T06:43:16+00:00

I am using PhoneGap and jQuery Mobile. I am trying to get some JSON

  • 0

I am using PhoneGap and jQuery Mobile. I am trying to get some JSON data from a remote location and then populate a local WebSQL database with it. Here is my JS function:

function getLocations() {

    var tx = window.openDatabase('csdistroloc', '1.0', 'Distro DB', 1000000);
    tx.transaction(function(tx) {
        tx.executeSql('DROP TABLE IF EXISTS locations'); //this line works!
        tx.executeSql('CREATE TABLE IF NOT EXISTS locations (id, name, address, postalcode, phone, category)'); //this line works!

        $.ajax({
          url: "http://mydomain.com/api.php",
          dataType: 'json',
          data: { action: "getlocations" },
          success: function(data) {
            tx.executeSql("INSERT INTO locations (id, name, address, postalcode, phone, category) VALUES (2,'cheese','232','seven',5,6)"); //this line produces an error
        }});

    }, dberror, dbsuccess);

}

Running the above function gives me an error “INVALID_STATE_ERR: DOM Exception 11” on the line noted above. It does the same thing when I am actually trying to use the returned JSON data to insert data. I have also tried the $.getJSON technique with the exact same result.

Any advice would be appreciated!

  • 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-05T06:43:18+00:00Added an answer on June 5, 2026 at 6:43 am

    I would first suggest not naming your database ‘tx’ but rather db or database. This could be a variable naming problem since both the function parameter and your database variables are called “tx”

    EDIT: I had this same problem and solved it by making the query within the callback it’s own transaction. Like so:

    success: function(data) {
    tx.transaction(function(transaction){
        transaction.executeSql("INSERT INTO locations (id, name, address, postalcode, phone, category) 
    VALUES (2,'cheese','232','seven',5,6)"); //now more DOM exception!
      }
    }}
    

    I think the problem is by the time the callback is fired the outer transaction has completed because webSQL’s transactions are not synchronous.

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

Sidebar

Related Questions

I am using PhoneGap, jQuery mobile in Xcode. I have a local xml (data.xml)
i'm using PhoneGap with JQuery mobile ajax to retrieve some records from a database
I'm using jquery mobile in a phonegap application and I'm trying to pass a
I am building an iPhone app using jQuery Mobile, jQuery 1.7.2, and PhoneGap trying
I have some strange scrolling problems with my PhoneGap (using jQuery Mobile) app: I'm
I'm using PhoneGap and JQuery Mobile. I'm trying to use custom button icons. I
This is for a jQuery Mobile app using version 1.0.1. I'm trying to get
I'm trying out PhoneGap 1.4 on Windows Phone 7.5 using jQuery mobile (1.0.1.). Basic
I am using PhoneGap 1.5.0, jQuery 1.7.1 and jQuery mobile 1.0.1 and trying to
I'm trying to make a mobile application using jQuery Mobile and Phonegap. But first

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.