[英]Post method in Angular JS
I have following code: 我有以下代码:
var req = {
method: 'POST',
url: '/customer',
headers: {
'Content-Type': 'application/json'
},
data: { test: 'testvalue' }
};
$http(req).then(function(){
console.log("f1")
},function(){
console.log("f2")
});
The code above posts this: 上面的代码发布了这一点:
{ '{"test":"testvalue"}': '' } {'{“ test”:“ testvalue”}':''}
When I need something like this: 当我需要这样的东西:
{"test":"testvalue"} { “测试”: “测试值”}
Does any one know the solution to this problem? 有谁知道解决这个问题的办法吗?
Use $http.post
method: 使用$http.post
方法:
$http.post('/customer', { test: 'testvalue' }, {
headers: {
'Content-Type': 'application/json'
}
}).then(function(){
console.log("f1")
},function(){
console.log("f2")
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.