Correct way to call an action from javascript?

I am starting to look at javascript for some of the tabs for my devices as I think it might make things a little easier. However, it is unclear to me how you would call an action. For instance, if I had two buttons in javascript, what is the right way to call “myAction1” when the first button is clicked, and “myAction2” when the second is clicked?

Digging around the forum I found this post : http://forum.micasaverde.com/index.php/topic,9211.msg60805.html#msg60805

That leads me to believe that I need to make an http call to do it. Would the proper way be something like this :

http://10.0.0.XX:3480/data_request?id=lu_action&serviceId=urn:myservice:serviceId:mydevice&action=RunLua&Code=luup.call_action()

Or is there a better way?

Also, is there someplace that these http calls are documented?

Thanks!

That’s how I did it. I have a niggling feeling that it’s not the “proper” way though.

As already linked above, I do it with http calls in the plugin variable container. This works realiably, even when connecting through mios.com or ob local lan’s.

But to be honest, I don’t think that’s the proper way. I’d love to hear about a cleaner approach.

The UI code uses either Ajax requests or SOAP requests, so the RunLua request appears to be the easiest way to call actions.

Thanks for all the responses!

It doesn’t seem very clean, but it does seem like it will get the job done until (if) there is a cleaner method in the future.

I am not sure if I get this right. Are you saying that using “RunLua” requests which are called by http are the best method as for the moment? Or is there another possibility to call “RunLua” request from java without using http?

Yes. The UI communicates with the back-end only through HTTP requests, and the RunLua HTTP request is the easiest for calling actions. The alternatives would be either Ajax requests, or SOAP requests.