从 Flex 应用程序向 Ruby on Rails 后端发送 post 请求时出现问题
我无法让我的 Flex 应用程序向我的 Rails 应用程序发送 POST 请求。 似乎总是发送GET。
这是我的服务声明:
<mx:HTTPService id="add_email_service" showBusyCursor="true" result="parseJoinResult();" fault="onJoinFault(event)" useProxy="false" />
在我的应用程序 init 函数中,我将方法设置为 POST:
add_email_service.url = join_url;
add_email_service.method = "POST";
但是,当我发送该请求时,我的 Rails 应用程序仍然将该请求视为 post 请求。 我知道这一点是因为如果我要求请求在我的routes.rb文件中进行POST:
# RESTful API for joining a mailing list
map.connect 'mailing_lists/join/:id',
:controller => 'mailing_lists',
:action => 'join',
:conditions => { :method => :post}
请求错误,我可以在我的开发日志中看到:
“Processing ApplicationController#index(for 127.0.0.1 at 2009-04-23 14:25) :35) [获取], ActionController::MethodNotAllowed(仅允许发布请求。):"
有谁知道为什么会发生这种情况?
I am having trouble getting my flex app to send a POST request to my Rails app. It seems to always send GET.
This is my service declaration:
<mx:HTTPService id="add_email_service" showBusyCursor="true" result="parseJoinResult();" fault="onJoinFault(event)" useProxy="false" />
In my application init function, I set the method to POST:
add_email_service.url = join_url;
add_email_service.method = "POST";
However, my Rails app still sees the request as a post request when I send it. I know this because if I require the request to be POST in my routes.rb file:
# RESTful API for joining a mailing list
map.connect 'mailing_lists/join/:id',
:controller => 'mailing_lists',
:action => 'join',
:conditions => { :method => :post}
the request faults and I can see in my dev log :
"Processing ApplicationController#index (for 127.0.0.1 at 2009-04-23 14:25:35) [GET],
ActionController::MethodNotAllowed (Only post requests are allowed.):"
Does anyone know why this is happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果没有发送变量,旧版本的 Flash Player(在某些浏览器中)会自动将您的请求从 POST 切换为 GET。
尝试在您的请求中添加一个参数,看看是否可以解决问题。
将 Flash Player 与 Restful Rails 集成?
还要为其他一些问题做好准备:
Older versions of the Flash Player (in some browsers) would automatically switch your request from POST to GET if there were no variables being sent.
Try adding a param to your request and see if that fixes it.
Integrating Flash Player with Restful Rails?
Get ready for some other issues too:
我相信实际上只有200。
I believe it's literally 200 only.