Reputation: 37
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.
Upvotes: 0
Views: 3184
Reputation: 1717
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.
Upvotes: 0
Reputation: 63
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.
Upvotes: 1
Reputation: 1
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
Upvotes: 0