I have been trying to achieve this, but it is not working. what im trying to do is that i have created a mysql database, and i want it that data to be displayed in my mobile app with the help of nodeJS. Database connectivity has been established and the data from the database is shown when i run the nodeJS file in npm terminal. My question is, can i make that data display in my cordova app.
Here is how my db.js page looks
var mysql = require('mysql');
var con = mysql.createConnection({
host: "localhost",
user: "root",
password: "",
database: "testdb"
});
con.connect(function(err) {
if (err) throw err;
con.query("SELECT * FROM animallist", function (err, result, fields) {
if (err) throw err;
console.log(result);
});
});
when i run this db.js in npm terminal, the output is shown below. The output is correct.
but can i display this data into the html file from cordova app in the data div. and this is what my html page in cordova looks like
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<div id="data"></div>
</body>
</html>
I went through a lot many posts on the internet, but i was unable to find a solution, Please if anyone can help.
Thanks in advance, Ivan Paul
