如何向mongodb发出ajax请求

编程入门 行业动态 更新时间:2024-10-27 21:19:32
本文介绍了如何向mongodb发出ajax请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用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请求

本文发布于:2023-10-09 18:54:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1476500.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:mongodb   ajax

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!