What could be causing a problem with the select query in SQLite for iOS using PhoneGap

Could someone please assist me with retrieving values from a database? Here is my code:

<script type="text/javascript" charset="utf-8">  
       // Wait for Cordova to load  
       document.addEventListener("deviceready", onDeviceReady, false);  
       // Cordova is ready  
       function onDeviceReady() {  
         console.log("Run1");  
         var db = window.sqlitePlugin.openDatabase({name: "MYDB"});  
         db.transaction(function (tx) {  
                 tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id unique, log)');  
         });  
         db.transaction(function (tx){  
                 for (var index = 1; index < 10; index++){  
                   tx.executeSql('INSERT INTO LOGS (id,log) VALUES ('+index+', '+index+')');  
                 }  
         });  
       }  
     </script>

A table has been created and 10 rows have been inserted. However, I am having trouble retrieving and displaying the values.

    <input id="DBlist" type="submit" onClick='showList()' data-theme="b" value="Saved values"  data-mini="false">

 function showList()
    {
 var db = window.sqlitePlugin.openDatabase({name: "MYDB2"});
  db.transaction(function(tx) {
  tx.executeSql("select * from LOGS;", [], function(tx, res) {
  // How can I display all the rows in console.log()?
   });
   });
  }

Any suggestions or advice would be greatly appreciated...

Answer №1

Check out the provided documentation

https://github.com/brodysoft/Cordova-SQLitePlugin

Here is a summarized version:

function(tx, res) {
    for (var i = 0; i < res.rows.length; i++) {
        console.log("Row = " + i + ", id = " + res.rows.item(i).id + ", log =  " +
                res.rows.item(i).log);
    }
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How can I make this NextJS component show its width as soon as the page loads?

When I try to run this code to retrieve the browser's screen width, I encounter the following error: ReferenceError: window is not defined The commented-out code works fine with a default value of 0 and updates correctly when the browser width chan ...

Creating a line of functions pool in Javascript with a delay feature

Recently, I created a code snippet that simulates a function line. It involves calling functions such as fn1, delay, fn2, delay, and so on. The idea is to call a function, remove it from the line, have a short sleep, and repeat. However, I've encount ...

Is there a way to include @odataid in an ajax request in order to invoke a post method that assigns an owner to a group?

Seeking assistance on how to utilize ajax for adding an Owner to an O365 group. Utilizing the following endpoint: https://graph.microsoft.com/v1.0/groups/{id}/owners/$ref This is my current ajax call setup, where I am passing user information through the ...

Unable to call upon JavaScript code from an external file

Just starting out with Spring and JavaScript! I've put together a JSP file https://i.sstatic.net/XemJ5.png In my first.js, you'll find the following method: function firstmethod() { window.alert("Enter a New Number"); return true; } H ...

AngularJS: Tips for bypassing filtering when inputting values outside of the range [1,2,3,4]

Is there a way to prevent filtering when entering certain numbers in the text box, like 0 or 5? <div ng-app=""> <input type="text" ng-model="search"> <div ng-repeat='val in [1,2, 3, 4] | filter:search'> {{val}} </div> ...

Error occurs consistently with AJAX, PHP, and SQL newsfeed

Striving for Progress Currently, I am engrossed in developing a newsfeed and enhancing my proficiency in utilizing Ajax through jQuery. My ultimate aim is to create a seamless user experience where individuals do not need to refresh the page to view the l ...

Dividing an AngularJS module across multiple iFrames on a single webpage

Currently, I am working on a web application that consists of 1 module, 5 pages, and 5 controllers. Each HTML page declares the same ng-app. These pages are loaded within widgets on a web portal, meaning each page is loaded within an iFrame in the portal. ...

Keeping track of segmented control value in a variable. What steps can be taken to resolve the warnings?

Here is the snippet of code I am currently working with. Despite receiving a warning about incompatible integer to pointer conversion, I am trying to assign an int value to the `qAVariable` variable based on the selected segment index. Can this still fun ...

JavaScript Regular Expression for standardizing phone number input

I'm working with an input for a phone number in French format which can accept two different formats: 0699999999 +33699999999 There is currently no check for the length of the number. In the database table, the field is varchar 12, but shorter inp ...

Upon the creation of a new Post and attempting to make edits, the field is found to be blank

<template> <div class="card m-3"> <div class="card-body"> <Form method="post" @submit="submitData" :validation-schema="schema" ref="myForm" v-slot="{ errors, ...

Failure to display React component on screen

I have developed a React microfrontend application consisting of two sub-apps rendered through the container/ project. Both sub-apps render perfectly in isolation on localhost:8083. However, when attempting to view them via localhost:8080/dashboard, I am p ...

How can I retain the selected item's information from a list in React JS when navigating to the next page?

In order to showcase various countries, I utilized ListItem in my Country.js file. For a visual representation of this setup, check out the CodeSandbox link I have provided: My Code One functionality I am aiming for is having the program remember the sel ...

Using Filters in VueJs

I am currently working on creating a small Vue.js 2.0 application where I am utilizing the v-select component from here. The data format that I am dealing with looks something like this: { "model": [ { "id":1, ...

The POST response I received was garbled and corrupted

Operating under the name DownloadZipFile, my service compiles data and constructs a Zip file for easy downloading. This particular service provides a response that contains the stream leading to the file. A Glimpse of the Service: [HttpPost] public Actio ...

There seems to be a glitch with the functionality of the HighStocks Tooltip

I've implemented a modified version of the example from highcharts: $(function () { $.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=?', function (data) { // Create the chart $('#co ...

How to interact with a C# List using JavaScript

Our internship project entails creating a business application using Unity WebGL. However, we're facing a challenge when it comes to retrieving a list from C# to populate a Select element on our webpage. We've successfully communicated and retrie ...

Utilizing ng-repeat, ng-grid, and ng-click in Angular: A comprehensive guide

I'm encountering an issue with populating a table using ng-repeat after a cellTemplate ng-click. cellTemplate: '<div ng-click="foo()" ng-bind="row.getProperty(col.field)"></div>' Within this foo method, I am tryi ...

Display information on a web page based on user input using HTML

I've hidden other p tags and divs using display:none, How can I make them visible after inputting my name? I'd like to type in my name and reveal all the content within the previously hidden div <form method="post"> <p> < ...

Encountering an issue with WebDriver in the realm of JavaScript

I am struggling to use JavaScript to locate specific controls and send values to them. One example is changing the text in a textbox with the ID "ID" to "123456". Below is the code I tried: ((IJavaScriptExecutor)driver).ExecuteScript("document.getElement ...

Encountered an issue loading resource: net::ERR_BLOCKED_BY_CLIENT while attempting to access NuxtJS API

After deploying my NuxtJS 2 app on Vercel and adding serverMiddleware to include an api folder in the nuxt.config.js file, everything was working smoothly. However, when I tried making an api call on my preview environment, I encountered an error: POST htt ...