Below is a snippet of code that I am working with:
var json_data = document.getElementById("json_data").value;
console.log(json_data);
tx.executeSql('INSERT INTO floodmaps VALUES (?,?,?)', [1, flodMapName, json_data], function(tx, res) {
//console.log(res);
console.log("rowsAffected: " + res.rowsAffected + " -- should be 1");
//console.log(res.rows.item(0).flood_name);
},
function(tx, error) {
console.log('INSERT error: ' + error.message);
});
tx.executeSql('SELECT *FROM floodmaps', [], function(tx, res) {
//console.log(res);
console.log(res.rows.item(0).id);
console.log(res.rows.item(0).flood_name);
console.log(res.rows.item(0).json_data);
},
function(tx, error) {
console.log('error: ' + error.message);
});
The purpose of this code is to retrieve the value from an input
element and then store that value in the database. However, I am encountering an issue as the value is not being saved. The debug console displays the following message:
rowsAffected: 1 -- should be 1
main.js:208 null
main.js:209 null
main.js:210 null
main.js:241 Transaction Successful
Interestingly, when I tried using sample data such as plain text or a single word, the data was successfully saved. What could potentially be causing this problem?
Feel free to access the data referenced in the code.