Simple:
<html>
<script>
function ajax(command){
console.log(command);
url="http://192.168.1.101/" + command;
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200)
console.log("Resp:" + xmlhttp.responseText);
};
xmlhttp.open("GET", url, true);
xmlhttp.send();
}
</script>
<button onmousedown="ajax('ledon');" onmouseup="ajax('ledoff');">GO</button>
<html>
function registra(idx){
log = document.getElementById("log")
var index = document.getElementById("nomiSel" + idx).selectedIndex;
var nome = document.getElementById("nomiSel" + idx).options[index].text;
var data = document.getElementById("data" + idx).textContent;
var badge = document.getElementById("badge" + idx).textContent;
//Recupera area e codice Orario
//alert(area);
if (window.XMLHttpRequest)
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
else// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200)
log.innerHTML=xmlhttp.responseText;
}
xmlhttp.open("GET","addons.php?nome=" + nome + "&data=" + data + "&badge=" + badge, true);
xmlhttp.send();
}
http://www.w3schools.com/ajax/ajax_xmlhttprequest_send.asp