What's new

Welcome to the forum 👋, Visitor

To access the forum content and all our services, you must register or log in to the forum. Becoming a member of the forum is completely free.

Help, can't send an object on HTML onclick

Barabba

New member
Joined
May 3, 2021
Messages
2
Reaction score
0
HTML Coins
0
Hi mates, my knowledge of HTML is really poor, I need help thanks.
I have a simple static page and I want to send to OBS an object to change the scene, the server expects something like this:
curl -XPOST -H "Content-type: application/json" -d '{"scene-name":"Scene 2"}' 'http://127.0.0.1/emit/SetCurrentScene'

somebody tried help me writing a script but it doesn't work, what is wrong here?

Code:
<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>

with Wireshark I see the browser sent the command, but it seems the object is missing

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

Server replies::
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

Thanks for help!
 

Theme customization system

You can customize some areas of the forum theme from this menu.

  • Wide/Narrow view

    You can control a structure that you can use to use your theme wide or narrow.

    Grid view forum list

    You can control the layout of the forum list in a grid or ordinary listing style structure.

    Picture grid mode

    You can control the structure where you can open/close images in the grid forum list.

    Close sidebar

    You can get rid of the crowded view in the forum by closing the sidebar.

    Fixed sidebar

    You can make it more useful and easier to access by pinning the sidebar.

    Close radius

    You can use the radius at the corners of the blocks according to your taste by closing/opening it.

  • Choose the color combination that reflects your taste
    Background images
    Color gradient backgrounds
Back