I just got to the HTML5 website and now I want to pass a few arguments to my worker.
I have this on my page:
var username = document.getElementById("username").value;
var server_url = 'localhost';
w.postMessage(username,server_url);
and this is with my employee:
var username = '';
var server_url = '';
onmessage = function (e,f) {
username = e.data;
server_url = f.data;
}
console.log(username);
console.log(server_url);
and when I open the page that calls the worker in the browser:
Uncaught TypeError: Failed to execute 'postMessage' on 'Worker': The 2nd argument is neither an array, nor does it have indexed properties.
all I want to do - is to transfer username
and server_url
the recipient I know that in the examples I hardcoded server_url
, but in the real script was dynamic.
Please don't just say: change it, do it, but provide me the code so that I can see how it should be done, and not still need to figure it out.
source
share