I am trying to send a URL over to ESP8266. Instead of sending the URL, I receive the entire webpage HTML and Javascript codes.
Here's my javascript code on my page:
jQuery(function($) {$("button").click(function(){
newurl = '/index.php?btn='+ this.id; //I WANT THIS....
sendHttpRequest(newurl);
});
});
function sendHttpRequest(update){
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
console.log(xhttp.responseText);
}
}
xhttp.open("GET",update);
xhttp.send(null);
}
And for my ESP8266 in my loop
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
while(!client.available()){
delay(10);
}
while(client.available()){
String request = client.readStringUntil('\r');
Serial.println(request);
}
Serial.println("closing connection");