-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetdata.html
65 lines (55 loc) · 1.69 KB
/
getdata.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>GetData</title>
</head>
<body>
数据
<div id="main" style="width: 600px;height: 400px"></div>
<!--<script>-->
<!--//用Ajax获得数据-->
<!--// var monthdata = {};-->
<!--var date = [];-->
<!--var value = [];-->
<!--var xmlHTTP = new XMLHttpRequest();-->
<!--xmlHTTP.onreadystatechange = function (ev) {-->
<!--if(xmlHTTP.readyState == 4 &&xmlHTTP.status == 200){-->
<!--var rep = JSON.parse(xmlHTTP.responseText);-->
<!--for(var i = 0; i < rep.length; i++){-->
<!--date.push(rep[i].date);-->
<!--value.push(rep[i].value);-->
<!--}-->
<!--console.log(date);-->
<!--console.log(value);-->
<!--}-->
<!--}-->
<!--xmlHTTP.open('GET','/uv/covid_test',true);-->
<!--xmlHTTP.send();-->
<!--// console.log(data);-->
<!--// console.log(value);-->
<!--</script>-->
<script>
var mysql = require('mysql');
var connection = mysql.createConnection({
host: 'localhost',
user: 'covid',
password: 'admin',
port: '3306',
database: 'covidhouse'
});
connection.connect();
var sql = 'select * from test';
connection.query(sql, function(err, result) {
if (err) {
console.log('[SELECT ERROR] - ', err.message);
return;
}
console.log('--------------------------SELECT----------------------------');
console.log(result);
console.log('------------------------------------------------------------\n\n');
});
connection.end();
</script>
</body>
</html>