Description
i am bit new in Esp8266 trying to build interactive code that make the data updated webserver eventually
so i have a html error trying to solve it but it seem something i dont know if anyone have the reason
my code in lua
`
data = 10
print (data)
srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
conn:on("receive",function(conn,payload)
local buf=""
local buf2=""
print(payload)
if data <1000 then data=data+1
elseif data>999 then data=0 end
tmr.delay(700000)
print (data)
buf = buf.."<!DOCTYPE HTML>\n\n"
buf = buf.."<html lang=\"en\" type=\"text/html\">\n"
buf = buf.."<head><meta charset=\"utf-8\" />\n"
buf = buf.."<title>Hello, World!</title></head>\n"
buf = buf.."<style>\n"
buf = buf.."html {\n"
buf = buf.."color: red;\n"
buf = buf.."background-color: #B39D99;\n"
buf = buf.."font-family :verdana,Arial ,Gemeva ,Arial Black;\n"
buf = buf.."}\n"
buf = buf.."</style>\n"
buf = buf.."<body onload='process()'>\n<h1>Hello, World!</h1>\n"
buf = buf.."<div id='div1'>"..data.."</div>\n"
buf = buf.."<script id=\"myxml\" type=\"text/XML\">\n"
-- buf=buf.." "
buf=buf..""
buf=buf..data
buf=buf.."\n\n"
buf = buf.."</script>\n"
buf = buf.."<script>\n"
buf=buf.."var xmlHttp=createXmlHttpObject();\n "
buf=buf.."function createXmlHttpObject(){;\n"
buf=buf.."if(window.XMLHttpRequest){\n"
buf=buf.."xmlHttp=new XMLHttpRequest();\n"
buf=buf.."}else{\n"
buf=buf.."xmlHttp=new ActiveXObject('Microsoft.XMLHTTP');\n"
buf=buf.."}\n"
buf=buf.."return xmlHttp; "
buf=buf.."\n"
buf=buf.."}\n"
buf=buf.."function response(){\n"
buf=buf.."xmlResponse=xmlHttp.responseXML;\n"
buf=buf.."xmldoc = xmlResponse.getElementByTagName('data').innerHTML;\n"
--buf=buf.." for (i = 0; i < x.length; i++) {\n"
--buf=buf.."if (areEqual = xmlDoc.getElementsByTagName(\'data\').toUpperCase() === nametxt.toUpperCase())\n" {
-- buf=buf.."document.getElementById(\"xml\").value = x[i];\n"
-- buf=buf.." }"
buf=buf.."message = xmldoc[0].firstChild.nodeValue;\n"
buf=buf.."document.getElementById('div1').innerHTML=message;}\n"
buf=buf.."function process(){\n"
buf=buf.."xmlHttp.open('PUT','XML',true);\n"
buf=buf.."xmlHttp.onreadystatechange=response;\n"
buf=buf.."xmlHttp.send(null);\n"
buf=buf.."setTimeout('process()',400);\n"
buf=buf.."}\n"
buf=buf.."</script>\n"
buf = buf.."</body>\n"
buf=buf.."</html>\n"
conn:send(buf);
conn:close();
collectgarbage();
end)
end)
`
and the error
(index):38 PUT http://192.168.1.8/XML net::ERR_CONNECTION_TIMED_OUT
process @ (index):38
(anonymous) @ VM10646:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10645:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10644:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10643:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10642:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10641:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10640:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10639:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10638:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10637:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10636:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10635:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10634:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10633:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10632:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10631:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10630:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10629:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10628:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10627:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10626:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10625:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10624:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10623:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10622:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10621:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10620:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10619:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10618:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10617:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10616:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10615:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10614:1
(index):32 Uncaught TypeError: Cannot read property 'getElementByTagName' of null
at XMLHttpRequest.response ((index):32)
response @ (index):32
XMLHttpRequest.send (async)
process @ (index):38
(anonymous) @ VM10646:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10645:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10644:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10643:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10642:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10641:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10640:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10639:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10638:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10637:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10636:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10635:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10634:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10633:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10632:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10631:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10630:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10629:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10628:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10627:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10626:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10625:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10624:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10623:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10622:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10621:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10620:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10619:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10618:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10617:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10616:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10615:1
(index):32 Uncaught TypeError: Cannot read property 'getElementByTagName' of null
at XMLHttpRequest.response ((index):32)
at process ((index):36)
at :1:1