Skip to content Skip to sidebar Skip to footer

Execute A Cgi Each Time A Button Was Clicked Without Changing The Current Html Page

I am starting my internship on a Home Server able to control mutliple domotics equipments from a web page. The global idea is that based on a click on a button, a certain script is

Solution 1:

Familiarize yourself with jQuery and its AJAX API. You can't make it not load a new page unless you use AJAX. Here is an example of what an AJAX call looks 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 is for jQuery 1.5 or higher. You can run that whenever a certain button is clicked like this:

HTML for the button:

<inputtype="button"id="doThis"/>

JavaScript:

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

Post a Comment for "Execute A Cgi Each Time A Button Was Clicked Without Changing The Current Html Page"