[英]cordova + angularjs + nodejs(Express) $http json always get 404
I am using cordova + angularjs + nodejs(Express) to test in android environment. 我正在使用cordova + angularjs + nodejs(Express)在android环境中进行测试。 Now I am trying to get some data by $http(), but I always get 404 error (by the alert below).
现在,我试图通过$ http()获取一些数据,但是我总是收到404错误(通过以下警报)。
Client Code ( AngularJs ) 客户代码(AngularJs)
$http({
method : 'POST',
url : "http://192.168.1.4:8888/login",
data : ""
})
.success(function(data, status, headers, config) {
alert("success");
alert(data);
})
.error(function(data, status, headers, config) {
alert("error");// <== always gets here
alert(status); // <== 404
}).
finally(function() {
alert("finally");
});
Server Code (NodeJs+Express) 服务器代码(NodeJs + Express)
...
app.get('/login',function(req, res){
res.set({'Content-Type':'application/json','Encodeing':'utf8'});
res.json({name:"jj"});
}) ;
app.listen(8888);
I can get the json string by visit http://192.168.1.4:8888/login by Chrome, 我可以通过Chrome访问http://192.168.1.4:8888/login来获取json字符串,
I searched a lot of stuff but still can't solve my problem, could anyone help? 我搜索了很多东西,但仍然无法解决我的问题,有人可以帮忙吗?
http方法是post,它需要被获取。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.