Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- routes/item.js
- ------------------------------------------------
- /* GET items listing */
- router.get('/', function(req, res, next) {
- Item.find({}, function(err, item) {
- if (err) {
- return console.log(err);
- }
- res.render('item/index', item);
- }).select('item_id item_name');
- });
- views/item/index.hbs
- -----------------------------------------------
- <div class="table-responsive no-padding" id="itemList">
- <table class="table table-hover table-striped">
- <thead>
- <th>No.</th>
- <th>Item ID</th>
- <th>Item Name</th>
- </thead>
- <tbody>
- <!-- populate table here -->
- </tbody>
- </table>
- <script type="text/javascript" src="/javascripts/global.js"></script>
- </div>
- public/javascripts/global.js
- -----------------------------------------------
- // DOM Ready =================
- $(document).ready(function() {
- // Populate table on initial page load
- populateTable();
- });
- function populateTable() {
- $.ajax({
- url: '/item',
- type: 'GET',
- success: function (item) {
- console.log(item);
- }
- });
- }
Add Comment
Please, Sign In to add comment