Bag - 0

Raspberry pi webcontrol

pascal
2.30K viewsRaspberry Pi
0

Hello,

I have a question about the video Raspberry pi webcontrol. I want to control my in and outputs from the web, so I build the example from the video.

The first part is working perfect, I can control my outputs with the seperate php scripts(pinon.php). But if I use the control.php script with the two buttons nothing happens. Can someone help me with this script?

Thanks, Pascal Martens

<!DOCTYPE html>
<html>
<head>
<meta charset=”UTF-8″>
<script scr=”http://code.jquery.com/jquery-1.11.0.min.js”></script>
<script type=”text/javascript”>
$(document).ready(function(){
$(‘#clickON’).click(funtion(){
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(funtion(){
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>

1

I’m not really sure what the problem might be based on your code. Do you get any errors? What I would recommend is using “Developer Tools” in Chrome or “Firebug” in Firefox to see if it throws back any errors when you try to load a page. then you can google that error to look for a quick fix. Hope that helps!

Question stats

  • Active
  • Views2297 times
  • Answers1 answer