Estoy tratando de crear una lista de tareas que puedo mostrar en el televisor de mi oficina que se recarga cada minuto, enviaré un correo electrónico a una cuenta de servicio y crearé un código para que agregue o elimine tareas en una fecha posterior. Actualmente solo intento que el sitio extraiga las tareas de un archivo de texto y actualice el sitio, pero no extrae los datos. Siento que puedo tener algo mal aquí, si alguien puede ayudar, se lo agradecería mucho.
Los archivos index.html y todo.txt están en el mismo directorio.
<head> <meta http-equiv="Content-Type" content="text/html; charset=utf8" /> <script type="text/javascript"> function refresh() { var req = new XMLHttpRequest(); console.log("Grabbing Value"); req.onreadystatechange = function () { if (req.readyState == 4 && req.status == 200) { document.getElementById('ToDo').innerText = req.responseText; } } req.open("GET", 'ToDo.txt', true); req.send(null); } function init() { refresh() var int = self.setInterval(function () { refresh() }, 10000); } </script> </head> <body onload="init()"> <div id="main"> <div id="updateMe"> <h2>To-Do List</h2> <h1 id="ToDo"></h1> </div> </div> </body> </html>Contenido de ToDo.txt
Purchase Things