Hallticket generation nodejs



<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>User Management</title>
<script src="
</head>
<body>
<div class="container" style="margin:20px" >
<table class="table table-striped table-bordered" id="example" >
<tr>
<th>PatientId</th>
<th>PatientName</th>
<th>Place</th>
<th>Download</th>
</tr>
<tbody id="dataa">
</tbody>
</table>
</div>
</body>
</html>
download.js

$(function(){
sessionStorage.setItem("id",null)
$.ajax({
type:"GET",
url:"http://127.0.0.1:3000/patient",
data:"",
success:function(json)
{
var result=JSON.parse(json);
alert(result);
$.each(result, function (index,obj) {
var tr=
"<tr><td>"+obj.patientid+"</td>"+
"<td>"+obj.patientname+"</td>"+
"<td>"+obj.patientplace+"</td>";
$('#dataa').append(tr);
});
},
error: function(err)
{
alert(err);
}
});
});
function Download(id){
sessionStorage.setItem("id",id)
window.location.assign("demo_add.html");
}
$(function(){
//$('#example').DataTable();
sessionStorage.setItem("id",null)
$.ajax({
type:"GET",
url:"http://127.0.0.1:3000/patient",
data:"",
success:function(json)
{
var result=JSON.parse(json);
alert(result);
$.each(result, function (index,obj) {
var tr=
"<tr><td>"+obj.patientid+"</td>"+
"<td>"+obj.patientname+"</td>"+
"<td>"+obj.patientplace+"</td>";
$('#dataa').append(tr);
});
},
error: function(err)
{
alert(err);
}
});
});
var http = require("http");
var express = require('express');
var app = express();
var mysql = require('mysql');
var bodyParser = require('body-parser');

var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : 'root',
database : 'excel'
});
connection.connect(function(err) {
if (err) throw err
console.log('You are now connected...')
})

app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With,
Content-Type, Accept");
res.header("Access-Control-Allow-Methods", "GET,PUT,POST,DELETE");
next();
});
app.use( bodyParser.json() );
app.use(bodyParser.urlencoded({
extended: true
}));


var server = app.listen(3000, "127.0.0.1", function () {
var host = server.address().address
var port = server.address().port
console.log("Example app listening at http://%s:%s", host, port)
});
app.get('/patient', function (req, res) {
connection.query('select * from excel', function (error, results, fields) {
if (error) throw error;
res.end(JSON.stringify(results));
});
});
app.get('/patient/:patientid', function (req, res) {
console.log(req);
connection.query('select * from excel where id=?', [req.params.id],
function (error, results, fields) {
if (error) throw error;
res.end(JSON.stringify(results));
});
});

No comments:

Post a Comment