I have a server in my ESP8266-01. The ESP8266 is in softAP mode. ESP8266WebServer.h
is used to create the server.
When I type 192.168.4.1/1/
in the browser, it returns a UI containing buttons. The buttons are generated from the following code:
addToBuffer("<div class=\"row\">");
for(i=1; i<5; i++) {
addToBuffer("<div class=\"col-md-2\"><button class=\"btn btn-block btn-lg btn-primary\" id='btn_on");
addToBuffer(clientId);
addToBuffer(i);
if(i==1)
addToBuffer("'>UP</button></div>");
if(i==2)
addToBuffer("'>LEFT</button></div>");
if(i==3)
addToBuffer("'>RIGHT</button></div>");
if(i==4)
addToBuffer("'>DOWN</button></div>");
}
addToBuffer("</div>");
// JavaScript for buttons
addToBuffer("<script type='javascript'>");
for(i=1; i<5; i++) {
addToBuffer("$('#btn_on");
addToBuffer(clientId);
addToBuffer(i);
addToBuffer("').click(function(){var xmlHttp = new XMLHttpRequest();xmlHttp.open(\"GET\",'/");
addToBuffer(clientId);
addToBuffer("/");
addToBuffer(i);
addToBuffer("/',false);});");
addToBuffer("xmlHttp.send(null);");
}
addToBuffer("</script>");
The server has handler functions for urls /
/1
, /1/1/
/1/2/
/1/3/
/1/4/
.
When I press any of the buttons, no request is being received in server. How to solve this?