Data Request
- 1 ответ
- 0 вопросов
1
Вклад в тег
var mysql = require('mysql');
var connection = mysql.createConnection({
database : 'mysql',
user : 'root',
password : 'toor'
});
var x={};
var query = function(){
connection.connect();
connection.query('SELECT 1 + 1 AS solution', function(err, rows, fields) {
if (err) throw err;
x = rows[0].solution;
});
connection.end();
};
var answer = function(){
return x;
};
module.exports.query = query;
module.exports.answer = answer;
<!DOCTYPE html>
<html>
<head>
<title>Hello World2!</title>
<script>
var mysql = require('./mysql.js');
function bodyOnLoad(){
mysql.query();
};
function getAnswer(){
document.getElementById("answer").innerHTML = mysql.answer();
}
</script>
</head>
<body onload="bodyOnLoad();">
<div id="answer" onClick="getAnswer;">Click me</div>
</body>
</html>
Оставь надежду всяк сюда входящий