This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

Javascript write to bus doesn't work
#1
Hi,

I've been trying to write an address to the bus using this javascript code:

$(function(){
  grp.write('2/5/1',true); 
});


Inside the browser console it appears this error:



Do you know what's happening? I'm pretty sure that I'd been using it before and it worked...

Thanks.
Reply
#2
Do you have any object on this page?
Reply
#3
Another possibility is that websocket is not connected yet. Try running the same grp.write call from browser console.
Reply
#4
(10.06.2020, 08:15)Daniel. Wrote: Do you have any object on this page?

Not in this sample. But I've tried adding an object and appears the same error...

(10.06.2020, 08:16)admin Wrote: Another possibility is that websocket is not connected yet. Try running the same grp.write call from browser console.

From browser console it works.
Reply
#5
How can we solve it?
Reply
#6
As admin mention add a delay before sending

Code:
$(function() {   
  setTimeout(() => { grp.write('2/5/1',true) }, 2000); 
});
Reply
#7
Ok, Thanks!
Reply


Forum Jump: