How to show loading message when making a ajax call in controller

267 views Asked by At

I have a Rhomobile Application, where i need some data to fetch from the server in the controller.

I have been using the below code,

result = Rho::AsyncHttp.get(
  :url => "http://www.example.com/API-vs-1"
)

@get_result = res["body"]

When i basically do a ajax call in javascript, i do have a LoadingMessage() and HideMessage() function which makes the loading screen.

So how and where can i do shomething to show a loading screen in here.

1

There are 1 answers

0
Ashis Kumar On BEST ANSWER

If you want, you can invoke the javascript functions from the controller itself by using WebView.execute_js(), http://docs.rhomobile.com/rhodesapi/webview-api#executejs

Here is how you can achieve this,

WebView.execute_js("LoadingMessage();")
result = Rho::AsyncHttp.get(
  :url => "http://www.example.com/API-vs-1"
)
WebView.execute_js("HideMessage();")
@get_result = res["body"]

You can give this a try, hope this helps you.