I tried removing the spaces as you suggested, no change. I think that the argument to the send function just needs to be a string anyway, so I don't think the spaces would matter. The function looks for a blank line to determine the end of the request. I was thinking that this was the problem, as there looks to be a blank line in you example before the name/value pair appears at the end of the POST request. I made some changes to get around this (not shown in code), but I'm still not seeing the name/value pair in the request. I also tried looking at this in the Explorer and Chrome developer tools, didn't see the name value pair appear.
I'm sure this is something very simple and something that will probably be very obvious once I solve the problem.
thanks!.............Steve
Here's the code, standard stuff from the ESP8266 library that was suggested above. I removed the code that would show the Arduino ADC conversion result in the browser and replaced it with my button and Javascript;
while (client.connected())
{
if (client.available())
{
char c = client.read();
index++;
mystring = mystring + (String)c;
Serial.write(c);
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank)
{
Serial.println("Sending response");
// send a standard http response header
// use \r\n instead of many println statements to speedup data send
client.print(
"HTTP/1.1 200 OK\r\n"
"Content-Type: text/html\r\n"
"Connection: close\r\n" // the connection will be closed after completion of the response
"Refresh: 20\r\n" // refresh the page automatically every 20 sec
"\r\n");
client.print("\r\n");
client.print("\r\n");
client.print("<script type="text/javascript">\r\n");
client.print("function button_event()\r\n");
client.print("{\r\n");
client.print("document.getElementById("my_button").innerHTML="blue";\r\n");
client.print("document.getElementById("my_button").style.color="white";\r\n");
client.print("document.getElementById("my_button").style.backgroundColor="blue";\r\n");
client.print("var request = new XMLHttpRequest();\r\n");
client.print("request.open("POST","192.168.1.117");\r\n");
client.print("request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");\r\n");
client.print("request.send("myvalue=hello");\r\n");
client.print("}\r\n");
client.print("\r\n");
client.print("\r\n");
client.print("<button id = "my_button" type="button" style="width:160;height:24; background-color:green" onclick="button_event()">Click Me!\r\n");
client.print("\r\n");
client.print("\r\n");
break;
}
if (c == '\n')
{
// you're starting a new line
currentLineIsBlank = true;
}
else if (c != '\r')
{
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}