Answer the question
In order to leave comments, you need to log in
Jtable integration with ExpressJs, anyone had experience with or similar tools?
Good day to all!
Not so long ago I switched to NodeJS and decided to practice, took on a simple task. I started doing it by reading the documentation. . . . etc.
And I ran into a problem, display a list on a table and decided to use jTable.org. only he does not want to work in any way and says:
the code on the client:
<script type="text/javascript">
$(document).ready(function () {
$('#nationality_table').jtable({
title: 'Person table',
ajaxSettings: {
type: 'POST',
dataType: 'json'
},
actions: {
// listAction: '/v1/api/nationality' /*'https://api.github.com/users/hadley/orgs'*/
listAction: function (postData) {
return $.ajax({
url: '/v1/api/nationality',
type: 'POST',
dataType: 'json',
data: postData,
})
},
createAction: '/GettingStarted/CreatePerson',
// updateAction: '/GettingStarted/UpdatePerson',
// deleteAction: '/GettingStarted/DeletePerson'
},
fields: {
_id: {
key: true,
list: false
},
desc: {
title: 'Author Name',
width: '40%'
}
}
});
// Load student list from server
$('#nationality_table').jtable('load');
});
</script>
exports.getJson = function(req, res){
Nationality.find(function(err, items) {
if(err) res.send(err);
res.set('Content-Type', 'application/json');
res.json(items);
});
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question