Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Arduino SD Card Web Page using Ajax with XML</title>
- <script>
- function GetArduinoInputs()
- {
- nocache = "&nocache=" + Math.random() * 1000000;
- var request = new XMLHttpRequest();
- request.onreadystatechange = function()
- {
- if (this.readyState == 4) {
- if (this.status == 200) {
- if (this.responseXML != null) {
- // extract XML data from XML file (containing switch states and analog value)
- document.getElementById("input1").innerHTML =
- this.responseXML.getElementsByTagName('button1')[0].childNodes[0].nodeValue;
- document.getElementById("input2").innerHTML =
- this.responseXML.getElementsByTagName('button2')[0].childNodes[0].nodeValue;
- document.getElementById("input3").innerHTML =
- this.responseXML.getElementsByTagName('analog1')[0].childNodes[0].nodeValue;
- }
- }
- }
- }
- request.open("GET", "ajax_inputs" + nocache, true);
- request.send(null);
- setTimeout('GetArduinoInputs()', 1000);
- }
- </script>
- </head>
- <body onload="GetArduinoInputs()">
- <h1>Arduino Inputs from SD Card Web Page using Ajax with XML</h1>
- <p>Button 1 (pin 7): <span id="input1">...</span></p>
- <p>Button 2 (pin 8): <span id="input2">...</span></p>
- <p>Analog (A2): <span id="input3">...</span></p>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement