I'm trying to control some RGB LEDs with ESP8266. I have built an HTML page to set the color and send the RGB color code to the ESP using HTTP get request. Everything works as expected. I just want to send an HTTP get request to the ESP and ask what the current color is. But after a couple of hours of searching and trying I don't know how to send data in response to get request, I just can send HTTP ok code. I'm using jquery to send get command as below
$.get("http://192.168.4.1/rgb(120,50,60)", function(data,status){
//I don't know how to send data fram ESP get it here.
});
this is the corresponding ESP response code written in Arduini IDE
WiFiClient client = server.available();
if (client) {
String req = client.readStringUntil('\r');
client.print("HTTP/1.1 200 OK\r\n");
client.print("Access-Control-Allow-Origin: *");
.
.
.
This is the HTTP header, How do I send some data(text)?
server.send(200, "text/plain", someStringOfContentHere);
build up the string with the data you need.