I would like to control my led lighting through webpage. I follow a YouTube tutorial, it works perfectly for pinon.php and pinoff.php.
However, it does not work for control.php, anybody knows the reason?
pinon.php
<?php
system("gpio -g mode 18 out");
system("gpio -g write 18 1");
?>
pinoff.php
<?php
system("gpio -g mode 18 out");
system("gpio -g write 18 0");
?>
control.php
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
                $('#clickON').click(function(){
                        var a = new XMLHttpRequest();
                        a.open("GET","pinon.php");
                        a.onreadystatechange=function(){
                                if(a.readyState==4){
                                        if(a.status == 200){
                                        }
                                        else alert("HTTP ERROR");
                                }
                        }
                        a.send();
                });
                $('#clickOFF').click(function(){
                        var a = new XMLHttpRequest();
                        a.open("GET","pinoff.php");
                        a.onreadystatechange=function(){
                                if(a.readyState==4){
                                        if(a.status == 200){
                                        }
                                        else alert("HTTP ERROR");
                                }
                        }
                        a.send();
                });
        });
    </script>
    <title>Pi controller</title>
</head>
<body>
    <button type="button" id="clickON">ON</button><br>
    <button type="button" id="clickOFF">OFF</button><br>
</body>
</html>
Link for the tutorial :Making Raspberry Pi Web Controls
 
    