Ciao, grazie per l'attenzione e per l'aiuto!
Ho bisogno di poter inviare un oggetto json a un piccolo server, per cambiare la scena a OBS, per farlo utilizzo una pagina statica html (no php ecc.), mi hanno consigliato questo ma non funziona:
Con wireshark vedo che il browser manda il push ma senza l'oggetto:codice HTML:<body> <div id="e0" class="cc08"> <a href="#" onclick="setCurrentScene('Scene2')"> <img src="logo.jpg" border="0" alt="Logo" title="Logo"> </a> </div> <script> function setCurrentScene(scenename) { var url = 'http://192.168.24.2:81/emit/SetCurrentScene'; var xhr = new XMLHttpRequest(); xhr.open('POST', url); xhr.setRequestHeader("Content-Type", "application/json"); xhr.onreadystatechange = function () { if (xhr.readyState === 4) { console.log(xhr.status); console.log(xhr.responseText); } }; var data = '{"scene-name":"'+scenename+'"}'; xhr.send(data); } </script>
E +q@À¨À¨¦FQ&´ô×P²çOPTIONS /emit/SetCurrentScene HTTP/1.1
Host: 192.168.24.2:81
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0
Accept: /
Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Access-Control-Request-Method: POST
Access-Control-Request-Headers: content-type
Origin: null
Connection: keep-alive
Il server risponde:
Eâ+v@À¨À¨Q¦F´ô×P²)HTTP/1.1 405 Method Not Allowed
Content-Type: text/plain; charset=utf-8
Allow: POST
Content-Length: 23
Date: Sat, 01 May 2021 09:47:09 GMT
Server: Python/3.8 aiohttp/3.7.4.post0
Cosa c'è che non va? Grazie mille