I am working on the basics of learning how to control Raspberry Pi GPIO from a web server. However, I am running into a problem. Here is my current set up.
index.html, the main webpage
<html>
<head>
<meta charset="utf-8" />
<title>Blink</title>
</head>
<body style="background-color: white;">
<!-- Button to call blink -->
<button type="button" onclick="blink()">blink</button>
<!-- javascript -->
<script src="script.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
</body>
script.js (where the I call php.php through ajax)
function blink() {
$.ajax({
url:"php.php", //the page containing php script
type: "POST", //request type
});
}
php.php, where I control the GPIO
<?php
exec("gpio -1 write 11 1");
sleep(1);
exec("gpio -1 write 11 0");
?>
Currently, the code works as far as controlling the GPIO works. I have an LED hooked up and it lights up and everything. However, I am receiving a dialog box in Chrome after every time the php file is done running. The dialog box is blank, and I assume it has something to do with either Ajax or Jquery returning an empty value. This is where my knowledge is lacking, and I would appreciate if someone could help me suppress this dialog box. Thank you!