I'm beginning my internship on the Home Server in a position to control mutliple domotics tools from the web site. The worldwide idea is the fact that with different click a control button, a particular script is created around the server and controls a microcontroller.

My tutor built an easy website he provided, using AJAX to continually remain on 1 page, and brings the menus based on user actions (they're hidden otherwise used, cut back to front if used).

I've setup an apache server that we set up to complete CGI scripts, and delay pills work. To continually remain on one page, I made use of the '204 No Content' return trick, to ensure that the server's response to the page is 'I do not have almost anything to say, just remain on this page'.

However the one problem I've would be that the CGI is released only one time. Basically click on the button the very first time it really works, later on nothing happens.

I attempted while using SSI (shtml) to make use of the inside a button code rather than utilizing a FORM with GET method however the script still will not execute two times.

I would be utilising the incorrect tools. Must I carry on with CGIs ? Or perhaps is there another thing (like AJAX, jquery) that really is made to do things i want ?

Thank you for getting read.

EDIT : I've discovered a means around it (it certainly is when I am desperate after searching for days to have an answer which i visit forums after which find myself a pleasant solution within the next hour .... ) I made use of a fundamental link, and for whatever reason it features a different behavior than utilizing a button. Whatever. My interrogations around the technologies used still stand though :)

EDIT2 : My option would be crappy, for whatever reason the script can also be known as at page refresh (or once the page loads the very first time). It's strange, because becasue it is within the it will simply be created after i click it ...

Acquaint yourself with jQuery and it is AJAX API. You cannot allow it to be not load a brand new page unless of course you utilize AJAX. Here's a good example of how much of an AJAX call appears like:

$.ajax({
    url: 'http://server.domain.com/cgi-bin/myfile.cgi',
    data: {
       x: 1,
       today: '20110504',
       user: 'Joe'
    }
}).success(function(data, status, xhr) {
    if (data)
        alert(data);
});

That's for jQuery 1.5 or greater. You are able to run any time a particular button is clicked on such as this:

HTML for that button:

<input type="button" id="doThis"/>

JavaScript:

$(function() {
    $('#doThis').click(function() {
        //put AJAX sample shown above, here
    });
});