AngularJS http.post()返回404

编程入门 行业动态 更新时间:2024-10-12 03:25:47
本文介绍了AngularJS http.post()返回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('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.headersmon['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 是不是一个真正的网站

cloud.email.aspx is not a real site.

推荐答案

解决我的问题。

添加CORS和服务器端的一些起源异常之后。我想我的code和成功得到了200状态响应,但Web服务也没做。读完这之后其他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

本文发布于:2023-10-10 09:46:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1478327.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:http   AngularJS   post

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!