我正在使用Meteor构建应用程序。我正在使用jquery datatables包-www.datatables展示我的数据/记录。根据文档,我可以通过以下方式将表连接到我的MongoDB数据库:
I am building an app using Meteor. I am using the jquery datatables package - www.datatables to present my data/records. According to the documentation, I would connect the table to my MongoDB database by:
$('#example').DataTable( { serverSide: true, ajax: '/data-source' });我不清楚的部分是第三行-有人可以帮助我了解如何制作Ajax调用以从我的MongoDB数据库返回数据?以下是有关数据表在服务器端处理的更多文档:
The part I am unclear of is the 3rd line - Can someone help me understand how to make an ajax call to return data from my MongoDB database?? Here is more documentation on server-side processing for datatables:
datatables/manual/server-side
我有一个名为Products的集合,其中包含字段描述,品牌,价格。
I have a collection named Products with the fields description, brand, price.
推荐答案<table id="example"> <thead id="dataTable-header"> <tr> <th>ID</th> <th>NAME</th> </tr> </thead> </table> var dataTable = $('#example').DataTable({ "orderable": false, 'searching': true, "paging": true, language: { processing: "<i class='fa fa-refresh fa-spin'></i>" }, "processing": true, "serverSide": true, "ajax": urlData, "columns":[ { "orderable": false, "class": "details-control", "data": null, "defaultContent": "" }, {"orderable": false, "data": "name" } ], "columnDefs": [{ "targets": 3, "render": function (data, type, row) { return '<a name="editAnchor" class="fa fa-ban"></a>'; }, "className": 'text-center' }] });
urlData是具有ID和Name字段的json数据。
urlData is your json data with fields Id and Name.
更多推荐
如何向mongodb发出ajax请求
发布评论