From 0204efc07ca8f48b68d8296fafb77340bd7b3ef2 Mon Sep 17 00:00:00 2001 From: vuko Date: Tue, 24 Nov 2020 16:56:16 +0100 Subject: [PATCH] add content-type header --- lights_web/static/index.html | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lights_web/static/index.html b/lights_web/static/index.html index 69b9db7..219afb7 100644 --- a/lights_web/static/index.html +++ b/lights_web/static/index.html @@ -218,6 +218,7 @@ return function(){ var toggle_request = new XMLHttpRequest(); toggle_request.open("POST", "/light/" + light.id + "/on/toggle", true); + toggle_request.setRequestHeader('Content-Type', 'application/json'); toggle_request.send(JSON.stringify(true)); }; }(light); @@ -226,9 +227,10 @@ return function ( lights ) { for ( i in lights ) { light = lights[i]; - var toggle_request = new XMLHttpRequest(); - toggle_request.open("POST", "/light/" + light.id + "/on/set", true); - toggle_request.send(JSON.stringify(true)); + var on_request = new XMLHttpRequest(); + on_request.open("POST", "/light/" + light.id + "/on/set", true); + on_request.setRequestHeader('Content-Type', 'application/json'); + on_request.send(JSON.stringify(true)); }; }; }(lights);