XML Http Request issue
Hi all,
first time here.
I am building a web page that connects to Vmix live video streaming software through IP and port on local network, once connected buttons on web page can trigger functions inside Vmix.
The issue i'm having is I cannot get the button to work properly from Animate CC Canvas as it triggers the function upon loading in browser and button does nothing.
It works as it should from basic .HTML with some javascript (code below) that I made in a text editor.
I am wondering what am I doing wrong inside animate?
(please bear with me as I am a beginner and only know basic javascript)
WORKING .html CODE:
<html>
<body>
<button onclick="httpGet('http://192.168.x.xxx:8088/api/?Function=OverlayInput2&Input=5')">Overlay 2</button>
<p id="demo"></p>
<script>
function httpGet(theUrl)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", theUrl, false); // false for synchronous request
xmlHttp.send(null);
return xmlHttp.responseText;
}
</script>
</body>
</html>
ANIMATE CC CODE: (button not working)
this.btn.onclick = httpGet('http://192.168.x.xxx:8088/api/?Function=Fade&Duration=1000');
function httpGet(theUrl) {
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", theUrl, false); // false for synchronous request
xmlHttp.send(null);
return xmlHttp.responseText;
}
link to the vmix api info: https://www.vmix.com/help19/index.htm?DeveloperAPI.html
