AngularJS http.post()返回404 [英] AngularJS http.post() returns 404
问题描述
Hi和祝你圣诞快乐所有。
Hi and merry christmas to you all.
我与PhoneGap的应用AngularJS工作。我试图做一个HTTP POST,但我把它返回一个404错误。我尝试了POST使用jQuery 1.10.2和它的作品。我已经在这个过天,这是最后的部分完成编码的应用程式。
I am working with a Phonegap AngularJS App. I am trying to make an http Post but I it returns an 404 error. I tried the POST using jquery 1.10.2 and it works. I have been days in this and it is the last part to finish coding the app.
我曾尝试不同的版本没有成功的要求。
I have tried different versions of the request with no success.
下面是code
$scope.sendMail = function (user){
console.log('sendmaul');
$http.post('https://cloud/email.aspx',
{
user: user.email,
pass: user.password,
to:user.recipient,
subject:'Test',
message:'My Message'
}
)
.success(function (data, status, headers, config){
console.log('success');
})
.error(function (data,status,headers,config){
console.log(data + status + config);
});
}
我,我需要一个angular.module以下code添加任意的.config
I have read in many places that I need to add on a angular.module the following code as .config
$httpProvider.defaults.useXDomain = true;
delete $httpProvider.defaults.headers.common['X-Requested-With'];
我补充说,controller.js code,但我看不到我的应用程序的行为差异。我也有工作非常好很多http.get()请求。
I added that code on controller.js but I don't see difference on behavior in my app. I also have many http.get() request that work really well.
- EDIT--
--EDIT--
的https://cloud.email.aspx 是不是一个真正的网站
https://cloud.email.aspx is not a real site.
推荐答案
解决我的问题。
添加CORS和服务器端的一些起源异常之后。我想我的code和成功得到了200状态响应,但Web服务也没做。读完这之后其他<一href=\"http://stackoverflow.com/questions/19254029/angularjs-http-post-does-not-send-data\">stackoverflow帖子我发现从不同的jQuery后Angularjs数据,因此常规的后读取Web服务是行不通的。该职位有一个链接到这个网站其中详细我的问题解释,它有一些code为发送数据以同样的方式jQuery不会。
After adding CORS and some Origins Exceptions on server side. I tried my code and got Success and 200 status response but the web service did nothing. After reading this other stackoverflow post I found out that Angularjs post data different from jquery so a normal POST read on the web service would not work. That post have a link to this site which explain in more detail my issue and it has some code for to send data the same way jquery does.
我希望这帮助别人
这篇关于AngularJS http.post()返回404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!