【发布时间】:2013-02-15 20:03:56
【问题描述】:
使用 angularJS 我有一个数据文件,我可以在其中与数据库进行通信。
因此,我想将数据发送到我从前端获得的数据以将其发送到 Packend,但不知何故这现在正在工作。你能帮帮我吗?
app.get('/api/data/:id', function (req, res) {
res.json({...});
});
app.post('/api/data/', function (req, res) {
res.json({
success: true
})
});
对于 get 和 delete 函数,这很好用,但我不知道如何制作 post 和 put 函数以及如何在其中获取数据。
我在客户端上做什么
add:function (data) {
location = '/api/data/';
$http.put(location, merchant, successCb).
success(function(data, status, headers, config) {
console.log(arguments);
successCb(data);
}).
error(function(data, status, headers, config) {
console.log('Error:' + arguments);
});
},
有人可以帮我如何在服务器和客户端上编写它。 (我在客户端及其简单的 javascript 对象上获得了正确的数据。
【问题讨论】:
-
您使用什么数据库系统?如果您向我们展示您在 get 中所做的事情,它也会有所帮助。例如,如果您想使用 MongoDB,可以阅读以下内容:pixelhandler.com/blog/2012/02/09/…
标签: javascript ajax node.js express angularjs