0
JavascriptのHTTPRequestを受信できないようです。私はこれを得るHTTP/1.1 200 OK
しかし、私は上に送信されたURLを取得するように見えることはできません。私は私のウェブページ上に送信しているリンクを望んでいます。空ループでESP8266はHTTPRequestを受信しません
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:ここ
は私のjavascriptのあるあなたが唯一のESP、上のindex.phpスクリプトからの応答の最初の行を読んでいるWiFiClient 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);