Rhomobile 罗兹 Rho AsyncHttp 帖子

发布于 2024-09-01 16:52:07 字数 100 浏览 9 评论 0原文

我在使用 Rhomobile rhodes 时遇到问题,请有人告诉我如何使用 Rho::AsyncHttp 进行 http post、获取、放置和删除? 我已经尝试了几个小时但没有成功。

I am having problems with Rhomobile rhodes, plaese can someone tell me how to make http post, get, put, and delete using Rho::AsyncHttp?
I've been trying it to no success for hours.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

很糊涂小朋友 2024-09-08 16:52:07

这是一些要放置在controller.rb文件中的示例代码

这是初始调用

  def index
  Rho::AsyncHttp.get(
    :url => 'http://the.page.you.want.to.get',
    :callback => (url_for :action => :httpget_callback),
    :callback_param => "" )      
  render :action => :wait  

结束

上面的代码将启动httpget_callback方法(如下)
当它关闭并加载 url 时,它将更改屏幕并加载 wait.erb 文件

  def httpget_callback
if @params['status'] != 'ok'
    @@error_params = @params
    WebView.navigate(url_for :action => :show_error )        
else
    @html = @params['body']
end
    WebView.navigate ( url_for :action => :show_result )

end

无需深入了解 - 返回页面的正文被放入 @html 变量中
希望有帮助,如果您需要更多帮助,请告诉我。

Here's some sample code to place in your controller.rb file

Here's the initial call

  def index
  Rho::AsyncHttp.get(
    :url => 'http://the.page.you.want.to.get',
    :callback => (url_for :action => :httpget_callback),
    :callback_param => "" )      
  render :action => :wait  

end

the code above will initiate the httpget_callback method (below)
while that goes off and loads the url it'll change the screen and load the wait.erb file

  def httpget_callback
if @params['status'] != 'ok'
    @@error_params = @params
    WebView.navigate(url_for :action => :show_error )        
else
    @html = @params['body']
end
    WebView.navigate ( url_for :action => :show_result )

end

Without getting too far into it - the body of the returned page is placed into @html variable
Hope that helps, if you need more help, let me know.

耳钉梦 2024-09-08 16:52:07

我有一个获取帖子的样本
res = Rho::AsyncHttp.post(:url => 'http://192.168.1.64 /WebServiceTest/Service.asmx/Sumar')
@msg=“同步http调用:#{res}”

http://wiki.rhomobile.com /index.php/RhodesConnectToWebServices

I have a sample of get an post
res = Rho::AsyncHttp.post(:url => 'http://192.168.1.64/WebServiceTest/Service.asmx/Sumar')
@msg= "Sync http call: #{res}"

http://wiki.rhomobile.com/index.php/RhodesConnectToWebServices

在你怀里撒娇 2024-09-08 16:52:07

我也经常在罗德岛中与 AsyncHttp 的细微差别作斗争,所以我还不能声称掌握了,但我真的觉得有必要提出一个建议:

我发现使用 Firefox 的 Firebug 插件在以下情况下非常有帮助:调试我的 Rhodes 应用程序。您可以非常轻松地将其连接起来!您可以通过将 Web 服务器配置为在特定端口上运行来使用任何浏览器加载您的应用程序。此设置位于 rhoconfig.txt 中,称为 local_server_port

这特别有用,因为您可以轻松地调查请求/响应的 HTML 和原始数据,并使用控制台运行 javascript 命令并实时使用 DOM 和网页。

I'm often struggling with the nuances of AsyncHttp in Rhodes as well, so I can't claim mastery yet, but I really felt the need to chime in with a suggestion:

I find using the Firebug plugin of Firefox to be VERY helpful when debugging my Rhodes app. You can hook it up very easily! You can load your app with any browser by configuring the web server to run on a specific port. This setting is in rhoconfig.txt and it is called local_server_port.

This is specifically helpful because you can easily survey the HTML and raw data of requests/responses and use the console to run javascript commands and play with the DOM and web page in realtime.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文