function httpGetAsync(theUrl) { var xmlHttp = new XMLHttpRequest(); xmlHttp.onreadystatechange = function() { if (xmlHttp.readyState == 4 && xmlHttp.status == 200) console.log(xmlHttp.responseText); }; xmlHttp.open("GET", theUrl, true); // true for asynchronous xmlHttp.send(null); }
$("form").submit(function(e){ if(document.getElementById('chkbox').checked) { console.log("irrigate on"); $(".notify").html("Irrigation is on"); httpGetAsync("irrigate_on.php") } else { console.log("irrigate off"); $(".notify").html("Irrigation is off"); httpGetAsync("irrigate_off.php") } e.preventDefault(); });
This is the base of the code. I will run the code for irrigation using the PHP file


















