calling the say function?
Hi Jimmy we're loving the TTS function - especially the kids making announcements around the house!
I managed to set up a webform with java script with the following command
window.open("http://192.168.0.3:5005/Living%20Room/say/" + jSay);
This works fine but clearly means it keeps opening brower windows. I also want to try and embed this in openremote. Is there a way to do this is in the background? I am a novice with javascript - I am guessing I need a post or get command??
It's better to use an XMLHttpRequest instead. If you need a simple wrapper to simplify this, you could use this one:
var HTTP = {
request: function (url, callback) {
var httpRequest = new XMLHttpRequest();
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState !== 4) return;
if (httpRequest.status === 200) {
// success
var responseJSON = JSON.parse(httpRequest.responseText);
callback(responseJSON);
return;
}
throw "Error";
}
httpRequest.open("GET", url);
httpRequest.send(null);
}
}
Now, you can use this to invoke a request:
HTTP.request("http://192.168.0.3:5005/Living%20Room/say/" + jSay, function (res) {});
(the second argument is a callback for a successful request, but you don't need to act on it)
Thanks very much for the help this works perfectly! Just wish I could understand what it was doing more....encourages me to have a read up on javascript.