tags:

views:

33

answers:

1

Hi

I'm new on AJAX. Just for fun I'm trying to control my sever via an AJAX interface. It's quite easy, for instance in PHP, to send a command to the server by the system() function and just a text field and a submit button.

The thing I'd like to do is to control in realtime some action, for example controlling music volume by a web interface, with a simple slide without any submit button.

Don't care about the way to control volume, is just a piece of example, imagine it like a php system() function.

WELL the question is: How can I implement such a remote control system**?** (The server is the machine that in this single case hosts the webserver).

+1  A: 

Have you already tried to do the control with a PHP only webinterface (e.g. reading requests like http://server/control.php?volume=10 or http://server/control.php?jumpToPercent=30)?

From there you can Ajaxify it partially e.g. by sending your form submits asynchronously via Ajax (recommending the jQuery form plugin). If you want to use a slider you could use the jQuery UI slider, which sends a request like

$.getJSON('http://server/control.php', { jumpToPercent : $(slider).percentValue() },
    function(data) { $(slider).value(data.value); }, 'json');

whenever it is changed (read the documentation for the correct events and invocations) and your PHP script changes the position and returns e.g.

{ "value" : 50 }

which is the new actual position of the slider.

Daff