Javascript'in HTTPRequest'sini alıyorum. Bu HTTP/1.1 200 OK
'u aldım, ancak gönderdiğim URL'yi alamıyorum. Sadece web sayfama gönderdiğim bağlantıyı istiyorum. hükümsüz döngüdeESP8266 HTTPRequest alınmıyor
jQuery(function($) {$("button").click(function(){
console.log(this.id);
document.getElementById("direction").innerHTML = this.id + " is pressed.";
newurl = 'index.php?btn='+ this.id+"?key="+user.key;
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,true);
xhttp.send(null);
console.log(update);
}
ESP8266: Burada
benim javascript yalnızca ESP, üzerinde index.php komut dosyasından yanıtın ilk satırı okuyorsanızWiFiClient client;
String url = "/index.php?";
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
Serial.println("Request Sent");
String request = client.readStringUntil('\r');
Serial.println("headers received");
Serial.println(request);