I'm trying to refresh table with SQL data by click the tab button but it doesn't work.
In app.js:
app.post('/updateTable', function(req, res) {
  var db = new sqlite3.Database('users.db');
  db.serialize(function() {
    db.all("SELECT * FROM user_info", function(err, rows) {
        res.render('index', { title: 'Student Registration', rows: rows });
    });
  });
  db.close();
});
In index.pug:
#tabs-2.box
  table
    thead
      tr#tabTit
        th Name
        th Birthday
        th EduID
        th EduGroup
        th Phone
        th Email
    tbody
      - for (var item in rows)
          tr
            td= rows[item].name
            td= rows[item].date
            td= rows[item].eduID
            td= rows[item].gr
            td= rows[item].phone
            td= rows[item].email
In clien-side JS:
$(document).ready( function() {
$('#tabs, #tabs-2').tabs({
      activate: function(event, ui) {
                $.ajax({
                  type: 'POST',
                  url: '/updateTable'
                });
      }
    });
});
The post-request is succefully handled but "res.render" does not work.
Where am I screwing up?
P.S. Sorry for my English
via Timu Sazon
 
No comments:
Post a Comment