[英]cordova + angularjs + nodejs(Express) $http json always get 404
我正在使用cordova + angularjs + nodejs(Express)在android環境中進行測試。 現在,我試圖通過$ http()獲取一些數據,但是我總是收到404錯誤(通過以下警報)。
客戶代碼(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");
});
服務器代碼(NodeJs + Express)
...
app.get('/login',function(req, res){
res.set({'Content-Type':'application/json','Encodeing':'utf8'});
res.json({name:"jj"});
}) ;
app.listen(8888);
我可以通過Chrome訪問http://192.168.1.4:8888/login來獲取json字符串,
我搜索了很多東西,但仍然無法解決我的問題,有人可以幫忙嗎?
http方法是post,它需要被獲取。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.