Advertisement
ghac

Untitled

Mar 14th, 2014
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. <html>
  2. <head>
  3. <!-- Script by Your Mother
  4. 14.03.2014
  5. -->
  6. <script type="text/javascript"> <!--
  7. var xhttp;
  8. var url_on = "http://jimpachnet.de/pi/on.php";
  9. var url_off = "http://jimpachnet.de/pi/off.php";
  10. var checkboxname = "onoff";
  11.  
  12. function createXMLHttpRequest() {
  13. if (window.ActiveXObject) {
  14. try {
  15. // IE 6 and higher
  16. xhttp = new ActiveXObject("MSXML2.XMLHTTP");
  17. } catch (e) {
  18. try {
  19. // IE 5
  20. xhttp = new ActiveXObject("Microsoft.XMLHTTP");
  21. } catch (e) {
  22. xhttp=false;
  23. }
  24. }
  25. }
  26. else if (window.XMLHttpRequest) {
  27. try {
  28. // Mozilla, Opera, Safari ...
  29. xhttp = new XMLHttpRequest();
  30. } catch (e) {
  31. xhttp=false;
  32. }
  33. }
  34. }
  35.  
  36. function sendRequest_on() {
  37.  
  38. if (!xhttp) {
  39. //alert("An Error occured when trying to initialize XMLHttpRequest!");
  40. return; // exit
  41. }
  42.  
  43. alert("On");
  44. xhttp.open("GET",url_on,true);
  45. xhttp.onreadystatechange=sendRequest_callback;
  46. xhttp.send(null);
  47.  
  48. }
  49.  
  50. function sendRequest_off() {
  51.  
  52. if (!xhttp) {
  53. //alert("An Error occured when trying to initialize XMLHttpRequest!");
  54. return; // exit
  55. }
  56.  
  57. alert("Off");
  58. xhttp.open("GET",url_off,true);
  59. xhttp.onreadystatechange=sendRequest_callback;
  60. xhttp.send(null);
  61.  
  62. }
  63.  
  64. function sendRequest_callback() {
  65. //alert ( xhttp.readyState);
  66.  
  67. if (xhttp.readyState==4 && xhttp.status==200){
  68. // alert ( xhttp.responseText );
  69. }
  70. }
  71.  
  72. function init() {
  73. createXMLHttpRequest();
  74. }
  75. window.onload=init;
  76.  
  77. function sendrightrequest(){
  78. if(document.getElementsByName(checkboxname)[0].checked){
  79. sendRequest_on();
  80. }else{
  81. sendRequest_off();
  82. }
  83. }
  84. // --> </script> </head> <body>
  85.  
  86. <form method="get" action="<?php echo basename(__FILE__);?>">
  87. <p><h4>Schalte die coolste LED der Welt, n&auml;mlich meine!<h4></p>
  88.  
  89. <input type="checkbox" name="onoff" value="on" onchange="javascript:sendrightrequest();"> AN/AUS<br>
  90. </form>
  91. </body>
  92. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement