I am unable to render data in html template but when I use express then inserted but file format is ejs . but I need listing my data in html without express. How to do that?
This is my server.js file here I have in this file database connection, insert record, select record and edit record query. Please see my code here is sjs templates.
Note: the problem is here is ejs templates but I want to render my nodejs code in .html format file not .ejs format.
server.js
var express = require('express'),
path = require('path'),
bodyParser = require('body-parser'),
emailExistence = require('email-existence'),
app = express(),
expressValidator = require('express-validator');
/*Set EJS template Engine*/
app.set('views','./views');
app.set('view engine','ejs');
app.use(express.static(path.join(__dirname, 'public')));
app.use(bodyParser.urlencoded({ extended: true })); //support x-www-form-urlencoded
app.use(bodyParser.json());
app.use(expressValidator());
/*MySql connection*/
var connection = require('express-myconnection'),
mysql = require('mysql');
app.use(
connection(mysql,{
host : 'localhost',
user : 'root',
password : '',
database : 'mydb',
debug : false //set true if you wanna see debug logger
},'request')
);
app.get('/',function(req,res){
res.send('Welcome');
});
//RESTful route
var router = express.Router();
/*------------------------------------------------------
* This is router middleware,invoked everytime
* we hit url /api and anything after /api
* like /api/user , /api/user/7
* we can use this for doing validation,authetication
* for every route started with /api
--------------------------------------------------------*/
router.use(function(req, res, next) {
console.log(req.method, req.url);
next();
});
var curut = router.route('/user');
//show the CRUD interface | GET
curut.get(function(req,res,next){
req.getConnection(function(err,conn){
if (err) return next("Cannot Connect");
var query = conn.query('SELECT * FROM t_user',function(err,rows){
if(err){
console.log(err);
return next("Mysql error, check your query");
}
res.render('user',{title:"RESTful Crud Example",data:rows});
});
});
});
//post data to DB | POST
curut.post(function(req,res,next){
//validation
req.assert('name','Name is required').notEmpty();
req.assert('email','A valid email is required').isEmail();
req.assert('password','Enter a password 6 - 20').len(6,20);
var errors = req.validationErrors();
if(errors){
res.status(422).json(errors);
return;
}
//get data
var data = {
name:req.body.name,
email:req.body.email,
password:req.body.password
};
//inserting into mysql
req.getConnection(function (err, conn){
if (err) return next("Cannot Connect");
var query = conn.query("INSERT INTO t_user set ? ",data, function(err, rows){
if(err){
console.log(err);
return next("Mysql error, check your query");
}
res.sendStatus(200);
});
});
});
//now for Single route (GET,DELETE,PUT)
var curut2 = router.route('/user/:user_id');
/*------------------------------------------------------
route.all is extremely useful. you can use it to do
stuffs for specific routes. for example you need to do
a validation everytime route /api/user/:user_id it hit.
remove curut2.all() if you dont want it
------------------------------------------------------*/
curut2.all(function(req,res,next){
console.log("You need to smth about curut2 Route ? Do it here");
console.log(req.params);
next();
});
//get data to update
curut2.get(function(req,res,next){
var user_id = req.params.user_id;
req.getConnection(function(err,conn){
if (err) return next("Cannot Connect");
var query = conn.query("SELECT * FROM t_user WHERE user_id = ? ",[user_id],function(err,rows){
if(err){
console.log(err);
return next("Mysql error, check your query");
}
//if user not found
if(rows.length < 1)
return res.send("User Not found");
res.render('edit',{title:"Edit user",data:rows});
});
});
});
//update data
curut2.put(function(req,res,next){
var user_id = req.params.user_id;
//validation
req.assert('name','Name is required').notEmpty();
req.assert('email','A valid email is required').isEmail();
req.assert('password','Enter a password 6 - 20').len(6,20);
var errors = req.validationErrors();
if(errors){
res.status(422).json(errors);
return;
}
//get data
var data = {
name:req.body.name,
email:req.body.email,
password:req.body.password
};
//inserting into mysql
req.getConnection(function (err, conn){
if (err) return next("Cannot Connect");
var query = conn.query("UPDATE t_user set ? WHERE user_id = ? ",[data,user_id], function(err, rows){
if(err){
console.log(err);
return next("Mysql error, check your query");
}
res.sendStatus(200);
});
});
});
//delete data
curut2.delete(function(req,res,next){
var user_id = req.params.user_id;
req.getConnection(function (err, conn) {
if (err) return next("Cannot Connect");
var query = conn.query("DELETE FROM t_user WHERE user_id = ? ",[user_id], function(err, rows){
if(err){
console.log(err);
return next("Mysql error, check your query");
}
res.sendStatus(200);
});
//console.log(query.sql);
});
});
//now we need to apply our router here
app.use('/api', router);
//start Server
var server = app.listen(4000,function(){
console.log("Listening to port %s",server.address().port);
});
user.ejs
This is my ejs view template files
<!DOCTYPE html>
<html>
<head>
<title><%=title%></title>
<script type="text/javascript" src="/../js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="/../js/all.js"></script>
<link rel="stylesheet" href="/../css/style.css">
</head>
<body>
<div class="data-table">
<table border="1" cellpadding="7" cellspacing="7">
<tr>
<th width="50px">No</th>
<th>Name</th>
<th>Email</th>
<th>Password</th>
<th>Action</th>
</tr>
<% if(data.length){
for(var i = 0;i < data.length;i++) { %>
<tr>
<td><%=(i+1)%></td>
<td><%=data[i].name%></td>
<td><%=data[i].email%></td>
<td><%=data[i].password%></td>
<td>
<a class="a-inside edit" href="/api/user/<%=data[i].user_id%>">Edit</a>
<a class="a-inside delete" href="javascript:void(0)" onClick="deleteUser(<%=data[i].user_id%>)">Delete</a>
</td>
</tr>
<% }
}else{ %>
<tr>
<td colspan="5">No Data</td>
</tr>
<% } %>
</table>
</div>
<div class="page-data">
<form method="post" action="" id="the-form">
<table cellpadding="11">
<tr>
<td class="label">Name</td><td>: <input type="text" name="name"></td>
</tr>
<tr>
<td class="label">Email</td><td>: <input type="text" name="email"></td>
</tr>
<tr>
<td class="label">Password</td><td>: <input type="password" name="password"></td>
</tr>
<tr>
<td class="label"></td>
<td>
<input type="button" value="Save" onClick="saveUser()">
</td>
</tr>
</table>
</form>
</div>
<div class="page-data">
<ul class="err-area"></ul>
</div>
<script>
function saveUser(){
$.ajax({
url:"/api/user",
type:"post",
data:$("#the-form").serialize(),
success:function(res){
window.location.reload();
return false;
},
error:function(xhr, status, error){
console.log(xhr.responseText);
var err = '';
$.each(JSON.parse(xhr.responseText) , function(i, item) {
err +='<li>'+item.msg+'</li>';
});
$(".err-area").html(err);
return false;
}
});
}
function deleteUser(user_id){
$.ajax({
url:"/api/user/"+user_id,
type: 'DELETE',
success: function(res) {
window.location.reload();
return false;
},
error:function(xhr, status, error){
console.log(xhr.responseText);
alert("Error deleting");
return false;
}
});
}
</script>
</body>
</html>
All you need is res.render("path to ejs file", {variables...}) to convert the ejs template to HTML response.
app.set('views','./views');
app.set('view engine','ejs');
This part takes care of the rendering HTML.
Related
So, basically I am trying to link two ejs files to express. The first one gets connected and displays result but second one that comes after pressing a button on first one shows error.
The user-list file displays results correctly but the exact same table code shows error in parks
parks.ejs (when I click the link in user-list that redirects here, it says userData not defined)
<div class="table-data">
<h2>Display Data using Node.js & MySQL</h2>
<table>
<tr>
<th>ID</th>
<th>Station N</th>
<th>Edit</th>
<th>Delete</th>
</tr>
<%
if(userData.length!=0){
var i=1;
userData.forEach(function(data){
%>
<tr>
<td><%=i; %></td>
<td><%=data.Station %></td>
<td>Edit</td>
<td>Delete</td>
</tr>
<% i++; }) %>
<% } else{ %>
<tr>
<td colspan="7">No Data Found</td>
</tr>
<% } %>
</table>
</div>
user-list.ejs
hello
++the table code shown above
users.js
var express = require('express');
var router = express.Router();
var db = require('../database');
router.get('/user-list', function(req, res, next) {
db.query("SELECT Station_ID FROM Station WHERE Name = 'A'", function (err, results, fields) {
if (err) throw err;
res.render('user-list', { title: 'User List', userData: results});
});
});
router.get('/parks', function(req, res, next) { //this part not working
db.query("SELECT Station_ID FROM Station WHERE Name = 'A'", function (err, results, fields) {
if (err) throw err;
res.render('parks', { title: 'User Listt', userData: results});
});
});
module.exports = router;
Worth noting is the app.js file because there I had to add app.get("/parks" line to link the two pages otherwise even the link didn't redirect to parks.ejs
var createError = require('http-errors');
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
const ejs = require('ejs');
var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');
var app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', indexRouter);
app.use('/users', usersRouter);
app.get("/parks", function(req,res){
res.render("parks");
});
// catch 404 and forward to error handler
app.use(function(req, res, next) {
next(createError(404));
});
// error handler
app.use(function(err, req, res, next) {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};
// render the error page
res.status(err.status || 500);
res.render('error');
});
module.exports = app;
hello
Here, the url is relative to the document root, so this will trigger your app.get("/parks") route handler - which actually doesn't seem to provide a userData variable.
If you want to trigger the router.get('/parks') handler from your user router, you should use a url relative to the current path.
hello
or
hello
I am creating a CRUD using MySQL, Node, AngularJS, and Express.
I am getting the response in the consoles but the data is not rendering in HTML pages.
The below-attached picture is the list of employees which is displayed on the HTML page as well as getting responses too: Displaying all employees
To get the details of the particular employee, click on show button. But by clicking on show button the data is showing in the consoles but not displaying in the HTML pages: Displaying employee details based on id
The code is as follows:
show.html
<div class="panel panel-default" ng-init="showEmployee()">
<div class="panel-heading">
<p class="panel-title"> Employee Detail Information</p>
</div>
<div class="panel-body">
<form>
<div class="form-group" ng-controller="empController">
<label class="form-control">Name: {{ employee.name }}</label>
<label class="form-control">Email: {{ employee.email }}</label>
<label class="form-control">Position: {{ employee.position }}</label>
<label class="form-control">Contact: {{ employee.contact }}</label>
<label class="form-control">ID: {{ employee.id }}</label>
Cancel
</div>
</form>
<div>
<div>
app.js
var myApp = angular.module('myApp',['ngRoute']);
myApp.config(function($routeProvider){
$routeProvider
.when('/', {
templateUrl:'templates/list.html',
controller:'empController'
})
.when('/employees', {
templateUrl:'templates/list.html',
controller:'empController'
})
.when('/employees/create', {
templateUrl:'templates/add.html',
controller:'empController'
})
.when('/employees/update/:id', {
templateUrl:'templates/edit.html',
controller:'empController'
})
.when('/employees/:id/show', {
templateUrl:'templates/show.html',
controller:'empController'
});
});
controller.js
myApp.controller('empController', function($scope,$route,$routeParams,$http){
$scope.getEmployees = function(){
$http.get('/employees').then(function(response){
console.log(response)
$scope.employees = response.data;
});
};
$scope.showEmployee = function(){
var id = $routeParams.id;
$http.get('/employees/'+ id).then(function(response){
console.log(response);
$scope.employee = response.data;
});
};
$scope.addEmployee = function(){
$http.post('/employees/create', $scope.employee).then(function(response){
//$scope.employee = response.data;
window.location.href = '/';
});
};
$scope.updateEmployee = function(){
var id = $routeParams.id;
$http.put('/employees/update/'+ id , $scope.employee).then(function(response){
window.location.href = '/';
});
};
$scope.deleteEmployee = function(id){
var id = id;
$http.delete('/employees/'+ id).then(function(response){
$route.reload();
});
};
});
server.js
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
var mysql = require('mysql');
app.use(bodyParser.urlencoded({extended:true}));
app.use(bodyParser.json());
app.use(express.static(__dirname + '/client'));
//start mysql connectio
var connection = mysql.createConnection({
host:'localhost',
user: 'root',
password:'12345',
database:'Employee'
});
connection.connect(function(err) {
if (err) throw err
console.log('You are now connected...')
})
//end mysql connectionselected
app.get('/employees', function(req, res){
connection.query("SELECT * FROM employees", function(err,results) {
if(err){
console.log(err);
res.json({"error": true});
}
else{
console.log(results);
res.end(JSON.stringify(results));
}
})
//}
//})
});
app.get('/employees/:id', function(req, res){
console.log(req);
connection.query('select * from employees where id=?', [req.params.id], function (error, results, fields) {
if (error) throw error;
console.log(results);
res.end(JSON.stringify(results));
});
});
app.post('/employees/create', function(req, res){
var postData = req.body;
connection.query('INSERT INTO employees SET ?', postData, function (error, results, fields) {
if (error) throw error;
res.end(JSON.stringify(results));
});
});
app.delete('/employees/:id', function(req, res){
console.log(req.body);
connection.query('DELETE FROM `employees` WHERE `id`=?', [req.body.id], function (error, results, fields) {
if (error) throw error;
res.end('Record has been deleted!');
});
});
app.put('/employees/update/:id', function(req, res){
app.put('/employees', function (req, res) {
connection.query('UPDATE `employees` SET `name`=?,`email`=?,`position`=?,`contact`=? where `id`=?', [req.body.name,req.body.email, req.body.position, req.body.contact, req.body.id], function (error, results, fields) {
if (error) throw error;
res.end(JSON.stringify(results));
})
});
});
app.listen(3000, function(){
console.log('server is running on port 3000..');
});
Can anyone please help me out?
Thank you in advance
$scope.showEmployee = function(){
var id = $routeParams.id;
$http.get('/employees/'+ id).then(function(response){
console.log(response);
// $scope.employee = response.data;
$scope.employee = response.data[0];
});
};
I got this simple code from a tutorial to a sample login html form to detect if user and the password are on my database for a user register or not.
this code can detect the email if exist but not the password.
what's wrong in here?
var express = require('express');
var app = express();
var server = require('http').createServer(app);
bodyParser = require('body-parser');
var mysql = require('mysql');
var connection = mysql.createConnection({
host: 'localhost',
database: 'chmult',
user: 'root',
password: '',
});
users = [];
connections = [];
app.get('/', function(req, res){
res.sendFile(__dirname + '/');
});
app.use(bodyParser.urlencoded({
extended: true
}));
/**bodyParser.json(options)
* Parses the text as JSON and exposes the resulting object on req.body.
*/
app.use(bodyParser.json());
connection.connect();
app.post('/', function(req, res){
var username= req.body.user.username;
var password = req.body.user.password;
connection.query('SELECT * FROM tesko WHERE username = ?',[username], function (error, results, fields) {
if (error) {
// console.log("error ocurred",error);
res.send({
"code":400,
"failed":"error ocurred"
})
}else{
// console.log('The solution is: ', results);
if(results.length >0){
if([0].password == password){
res.send({
"code":200,
"success":"login sucessfull"
});
}
else{
res.send({
"code":204,
"success":"Email and password does not match"
});
}
}
else{
res.send({
"code":204,
"success":"Email does not exits"
});
}
}
});
});
app.listen(3231);
console.log('Example app listening at port:3231');
my html forms
<form method="post" action="">
<input type="text" name="user[username]">
<input type="text" name="user[password]">
<input type="submit" value="Submit">
</form>
</html>
The column names on my table are (username,password). Both are varchar and I tried with other table that have md5. Still can't detect the password.
this bit of code looks suspicious:
if(results.length >0){
if([0].password == password){
res.send({
"code":200,
"success":"login sucessfull"
});
}
particularly [0].password I'd expect that to be undefined.
[0] is an array literal here, instead of an index into an array. You probably want results[0].password instead, judging by the line before it.
I am trying to be able to print mysql data to a html page just to test it so i can start learning
Upadated Code
here is what i have tried on my server.js
var mysql = require("mysql");
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
app.get('/', function(req, res){
res.sendfile('testsql.html');
//res.sendfile('/login/');
});
http.listen(3000, function(){
console.log('listening on *:3000');
});
var con = mysql.createConnection({
host: "localhost",
user: "root",
password: "password",
database: "users"
});
io.on('connection', function (socket) {
console.log('a client connected');
con.query('SELECT * FROM users',function(err,rows){
if(err) throw err;
console.log('Data received from Db:\n');
console.log(rows);
socket.emit('showrows', rows);
});
});
**And Here is My Client Code **
<!doctype html>
<html>
<head>
<title>Testing socket.io</title>
</head>
<body>
<h1 id="socketio"> not connected </h1>
<div id="display"> </div>
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io();
socket.on('connect', function() {
document.getElementById("socketio").innerHTML = "socket connected";
});
socket.on('showrows', function(dbData) {
document.getElementById("display").innerHTML = dbData;
});
</script>
</body>
</html>
the client is showing that it is connecting to the server but it is not displaying the query result on the client
You can try the following changes:
in the server:
var con = mysql.createConnection({
host: "localhost",
user: "root",
password: "password",
database: "users"
});
io.on('connection', function (socket) {
console.log('a client connected');
con.query('SELECT * FROM users',function(err,rows){
if(err) throw err;
console.log('Data received from Db:\n');
console.log(rows);
socket.emit('showrows', rows);
});
});
in the client:
<!doctype html>
<html>
<head>
<title>Testing socket.io</title>
</head>
<body>
<h1 id="socketio"> not connected </h1>
<div id="display"> </div>
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io();
socket.on('connect', function() {
document.getElementById("socketio").innerHTML = "socket connected";
});
socket.on('showrows', function(rows) {
var html='';
for (var i=0; i<rows.length; i++) {
html += rows[i].firstname + ' ' + rows[i].lastname + '<br>';
}
document.getElementById("display").innerHTML = html;
console.log(rows);
});
</script>
</body>
</html>
I see the following typo: socket.brodcast.emit('showrows', rows); which should be socket.broadcast.emit('showrows', rows);
But in your case, you only need socket.emit('showrows', rows). And in order to listen to this on the client side, you need to have this:
socket.on('showrows', function(rows){
console.log(rows);
jQuery("#display").append(rows);
});
First, you are trying to create a connection to mysql server twice.
And I believe there is something that you missed out for your client side.You forgot to connect to your socket.io server.
var socket = io.connect('http://localhost:3000', {'reconnect': true, 'force new connection': true, 'connect timeout': 1000});
socket.on('showrows', function(rows) {
jQuery("#display").append(rows);
});
You should also make sure your client is connected to the server before emitting your query result.
io.sockets.on('connection', function (socket) {
//Run your mysql query method
//Socket disconnected
socket.once('disconnect', function () {
});
});
Update: Only end the mysql connection when you are done querying.
con.connect(function(err){
if(err){
console.log('Error connecting to Db');
return;
}
console.log('Connection established');
});
//Don't recreate a mysql connection
con.query('SELECT * FROM users',function(err,rows){
if(err) throw err;
console.log('Data received from Db:\n');
console.log(rows);
});
con.end(function(err) {
// The connection is terminated gracefully
// Ensures all previously enqueued queries are still
// before sending a COM_QUIT packet to the MySQL server.
});
I'm trying to run 2 queries against a MySQL database and they are not working. And display it, getting errors, can I do this a better way? I'm mainly asking how to display it in the home.handlebars file and how to make more than 1 query from MySQL database.
var express = require('express');
var handlebars = require('express-handlebars');
var bodyParser = require('body-parser')
var mysql = require('mysql');
var app = express();
app.engine('handlebars', handlebars({defaultLayout: 'main'}));
app.set('views', __dirname + '/views');
app.set('view engine', 'handlebars');
app.use(express.static('public'));
app.use(bodyParser.json()); // support json encoded bodies
app.use(bodyParser.urlencoded({ extended: true })); // support encoded bodies
var connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: 'root',
database: 'translation_project'
});
connection.connect();
app.get('/', function(req, res) {
var translatorid = 45;
var sqlQuery = "SELECT title,type FROM itemtable;"
connection.query(sqlQuery,function(err,rows,fields){
if(err){
console.log('Error'+err);
}else{
res.render('home',{items:rows}); // to be displayed in the home page
}
});
var sqlQuery2 = "SELECT dateoftranslation FROM translateditems;"
connection.query(sqlQuery2,function(err,rows,fields){
if(err){
console.log('Error'+err);
}else{
res.render('home',{dates:rows}); // to be displayed in the home page
}
});
});
app.listen(3000, function() {
console.log('Server is running at port 3000');
});
and Here is the home.handlebars file
<h1> My Applied Items </h1>
{{#each items}} <!-- the items refreneced in the index page-->
<p>{{title}}</p>
<p>{{type}}</p>
{{/each}}
{{#each dates}} <!-- the dates refreneced in the index page-->
<p>{{dateoftranslation}}</p>
{{/each}}
and Here is the home.handlebars file
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Users Profile</title>
</head>
<body>
<h1> Mohamed </h1>
{{{body}}}
</body>
</html>
I would consider using Promises so you can wait for both queries to return before sending the result to the client:
function query(sqlQuery) {
return new Promise(function (resolve, reject) {
connection.query(sqlQuery, function (err, result) {
if (err) {
reject(err);
} else {
resolve(result);
}
});
});
}
app.get('/', function (req, res) {
var query1 = query("SELECT title,type FROM itemtable;");
var query2 = query("SELECT dateoftranslation FROM translateditems;");
Promise.all(query1, query2).then(function (result) {
res.render('home', {
items: result[0],
dates: result[1]
});
});
});
You should do it in callback nesting due to asynchronous nature of connection.query().
app.get('/', function(req, res) {
var translatorid = 45;
var sqlQuery = "SELECT title,type FROM itemtable;",
sqlQuery2 = "SELECT dateoftranslation FROM translateditems;";
connection.query(sqlQuery,function(err,rows1){
if(err){
console.log('Error'+err);
}
else{
connection.query(sqlQuery2,function(err,rows2){
if(err){
console.log('Error'+err);
}
else{
res.render('home',{items:rows1,dates:rows2});
}
});
}
});
});
If you are performing several queries and you don't want Callback nesting(Due to non-readability of multi-nesting callbacks) then you should try promise or you can do that async way.
below is async way.
var async=require('async');
connection.connect();
app.get('/', function(req, res) {
var translatorid = 45;
var sqlQuery = "SELECT title,type FROM itemtable;",
sqlQuery2 = "SELECT dateoftranslation FROM translateditems;",
sqlQuery3="someQuery",
sqlQuery4="someOtherQuery",
sqlQuery5="someOtherOtherQuery";
async.parallel([function(cb){
connection.query(sqlQuery,function(err,rows1){
if(err){
console.log('Error'+err);
cb(err);
}
else{
cb(null,rows1);
}
});
},function(cb){
connection.query(sqlQuery2,function(err,rows2){
if(err){
console.log('Error'+err);
cb(err);
}
else{
cb(null,rows2);
}
});
},function(cb){
connection.query(sqlQuery3,function(err,rows3){
if(err){
console.log('Error'+err);
cb(err);
}
else{
cb(null,rows3);
}
});
},function(cb){
connection.query(sqlQuery4,function(err,rows4){
if(err){
console.log('Error'+err);
cb(err);
}
else{
cb(null,rows4);
}
});
},function(cb){
connection.query(sqlQuery5,function(err,rows5){
if(err){
console.log('Error'+err);
cb(err);
}
else{
cb(null,rows5);
}
});
}],function(err,results){
if(err){
// out of those 5 tasks at least one caused some error.
// handle that.
return;
}
// no error occurred.
var rows1=results[0],
rows2=results[1],
rows3=results[2],
rows4=results[3],
rows5=results[4];
res.render('home',{items:rows1,dates:rows2,other1:rows3,other2:rows4,other3:rows5});
});
});