Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #21442 > unrolled thread
| Started by | dman777 <darin.hensley@gmail.com> |
|---|---|
| First post | 2013-09-27 08:09 -0700 |
| Last post | 2013-09-27 10:57 -0700 |
| Articles | 6 — 2 participants |
Back to article view | Back to comp.lang.javascript
Javascript postMessage Syntax Error DOM Exception in Web Worker Code dman777 <darin.hensley@gmail.com> - 2013-09-27 08:09 -0700
Re: Javascript postMessage Syntax Error DOM Exception in Web Worker Code Martin Honnen <mahotrash@yahoo.de> - 2013-09-27 17:47 +0200
Re: Javascript postMessage Syntax Error DOM Exception in Web Worker Code dman777 <darin.hensley@gmail.com> - 2013-09-27 08:52 -0700
Re: Javascript postMessage Syntax Error DOM Exception in Web Worker Code Martin Honnen <mahotrash@yahoo.de> - 2013-09-27 18:57 +0200
Re: Javascript postMessage Syntax Error DOM Exception in Web Worker Code dman777 <darin.hensley@gmail.com> - 2013-09-27 10:09 -0700
Re: Javascript postMessage Syntax Error DOM Exception in Web Worker Code dman777 <darin.hensley@gmail.com> - 2013-09-27 10:57 -0700
| From | dman777 <darin.hensley@gmail.com> |
|---|---|
| Date | 2013-09-27 08:09 -0700 |
| Subject | Javascript postMessage Syntax Error DOM Exception in Web Worker Code |
| Message-ID | <943c4469-b974-4dbc-8da5-75a4a04be456@googlegroups.com> |
I am using Javascript Web Workers. In the web worker, I have:
function makeRequestChat(id) {
var jsonObj;
var xml = new XMLHttpRequest();
xml.open("POST", "/site/myapp/" + id, true);
xml.onreadystatechange = function () {
if (xml.readyState === 4 && xml.status === 200){
var jsonObj = JSON.parse(xml.responseText, function (key,value) { parseChat(key, value, id); });
var foo = chatQueues[id];
foo.queue = id;
var bar = JSON.stringify(foo);
postMessage(bar);
}
}
xml.send(null);
}
I am using copy for sending the json string. I get Uncaught Error: SyntaxError: DOM Exception 12 get.js:28 xml.onreadystatechange. This is specifically at postMessage(bar). This is strange there is nothing DOM related in this web workers code. I really need to get rid of this error if anyone can please help!
Here is the json string being returned to main:
"{"active":0,"unanswered":0,"available":3,"queue":"uk"}"
I am desperate to get rid of this error if anyone can please help.
[toc] | [next] | [standalone]
| From | Martin Honnen <mahotrash@yahoo.de> |
|---|---|
| Date | 2013-09-27 17:47 +0200 |
| Message-ID | <5245a88d$0$6639$9b4e6d93@newsspool2.arcor-online.net> |
| In reply to | #21442 |
dman777 wrote:
> I am using Javascript Web Workers. In the web worker, I have:
>
> function makeRequestChat(id) {
> var jsonObj;
> var xml = new XMLHttpRequest();
> xml.open("POST", "/site/myapp/" + id, true);
> xml.onreadystatechange = function () {
> if (xml.readyState === 4 && xml.status === 200){
> var jsonObj = JSON.parse(xml.responseText, function (key,value) { parseChat(key, value, id); });
> var foo = chatQueues[id];
> foo.queue = id;
> var bar = JSON.stringify(foo);
> postMessage(bar);
>
> }
> }
> xml.send(null);
> }
> I am using copy for sending the json string. I get Uncaught Error: SyntaxError: DOM Exception 12 get.js:28 xml.onreadystatechange. This is specifically at postMessage(bar). This is strange there is nothing DOM related in this web workers code. I really need to get rid of this error if anyone can please help!
Which browser gives that error message? Do you get an error in other
browsers too?
[toc] | [prev] | [next] | [standalone]
| From | dman777 <darin.hensley@gmail.com> |
|---|---|
| Date | 2013-09-27 08:52 -0700 |
| Message-ID | <a595ebd6-6fc3-4a58-9981-2ca7bebc2d9b@googlegroups.com> |
| In reply to | #21442 |
On Friday, September 27, 2013 10:09:24 AM UTC-5, dman777 wrote:
> I am using Javascript Web Workers. In the web worker, I have:
>
>
>
> function makeRequestChat(id) {
>
> var jsonObj;
>
> var xml = new XMLHttpRequest();
>
> xml.open("POST", "/site/myapp/" + id, true);
>
> xml.onreadystatechange = function () {
>
> if (xml.readyState === 4 && xml.status === 200){
>
> var jsonObj = JSON.parse(xml.responseText, function (key,value) { parseChat(key, value, id); });
>
> var foo = chatQueues[id];
>
> foo.queue = id;
>
> var bar = JSON.stringify(foo);
>
> postMessage(bar);
>
>
>
> }
>
> }
>
> xml.send(null);
>
> }
>
> I am using copy for sending the json string. I get Uncaught Error: SyntaxError: DOM Exception 12 get.js:28 xml.onreadystatechange. This is specifically at postMessage(bar). This is strange there is nothing DOM related in this web workers code. I really need to get rid of this error if anyone can please help!
>
>
>
> Here is the json string being returned to main:
>
> "{"active":0,"unanswered":0,"available":3,"queue":"uk"}"
>
>
>
> I am desperate to get rid of this error if anyone can please help.
Hello,
Thank you for your reply. I get this in chromium Version 28.0.1500.71 (209842). When I try this in firefox, I do not get this error. But I do get this instead:
"Timestamp: 09/27/2013 10:49:16 AM
Error: NS_ERROR_XPC_NOT_ENOUGH_ARGS: Not enough arguments [nsIDOMWindow.postMessage]
Source File: http://10.14.213.69/js/get.js
Line: 28"
[toc] | [prev] | [next] | [standalone]
| From | Martin Honnen <mahotrash@yahoo.de> |
|---|---|
| Date | 2013-09-27 18:57 +0200 |
| Message-ID | <5245b916$0$6641$9b4e6d93@newsspool2.arcor-online.net> |
| In reply to | #21444 |
dman777 wrote: > Thank you for your reply. I get this in chromium Version 28.0.1500.71 (209842). When I try this in firefox, I do not get this error. But I do get this instead: > > "Timestamp: 09/27/2013 10:49:16 AM > Error: NS_ERROR_XPC_NOT_ENOUGH_ARGS: Not enough arguments [nsIDOMWindow.postMessage] > Source File: http://10.14.213.69/js/get.js > Line: 28" That error suggests the `postMessage` you are calling is not a WebWorker's postMessage but a DOM window's postMessage.
[toc] | [prev] | [next] | [standalone]
| From | dman777 <darin.hensley@gmail.com> |
|---|---|
| Date | 2013-09-27 10:09 -0700 |
| Message-ID | <9dc3e0d0-b7d7-45de-af2b-431c2b922f7c@googlegroups.com> |
| In reply to | #21442 |
On Friday, September 27, 2013 10:09:24 AM UTC-5, dman777 wrote:
> I am using Javascript Web Workers. In the web worker, I have:
>
>
>
> function makeRequestChat(id) {
>
> var jsonObj;
>
> var xml = new XMLHttpRequest();
>
> xml.open("POST", "/site/myapp/" + id, true);
>
> xml.onreadystatechange = function () {
>
> if (xml.readyState === 4 && xml.status === 200){
>
> var jsonObj = JSON.parse(xml.responseText, function (key,value) { parseChat(key, value, id); });
>
> var foo = chatQueues[id];
>
> foo.queue = id;
>
> var bar = JSON.stringify(foo);
>
> postMessage(bar);
>
>
>
> }
>
> }
>
> xml.send(null);
>
> }
>
> I am using copy for sending the json string. I get Uncaught Error: SyntaxError: DOM Exception 12 get.js:28 xml.onreadystatechange. This is specifically at postMessage(bar). This is strange there is nothing DOM related in this web workers code. I really need to get rid of this error if anyone can please help!
>
>
>
> Here is the json string being returned to main:
>
> "{"active":0,"unanswered":0,"available":3,"queue":"uk"}"
>
>
>
> I am desperate to get rid of this error if anyone can please help.
Wow, interesting. Here is my main:
var worker1 = new Worker("js/get.js");
worker1.addEventListener("message", tell, false);
worker1.postMessage();
function tell(event) {
var foo = JSON.parse(event.data);
chatQelements(foo);
}
function chatQelements(foo) {
var bar = document.getElementById("active" + foo["queue"]);
bar.textContent = "Active: " + foo["active"];
bar = document.getElementById("unans" + foo["queue"]);
bar.textContent = "Unanswered: " + foo["unanswered"];
bar = document.getElementById("avail" + foo["queue"]);
bar.textContent = "Available: " + foo["available"];
}
How do I direct the workers postMessage(bar) to send the message to worker1.addEventListener("message", tell, false);?
[toc] | [prev] | [next] | [standalone]
| From | dman777 <darin.hensley@gmail.com> |
|---|---|
| Date | 2013-09-27 10:57 -0700 |
| Message-ID | <d6eecbec-2c23-4ca8-b068-f9ddd035de17@googlegroups.com> |
| In reply to | #21446 |
On Friday, September 27, 2013 12:09:15 PM UTC-5, dman777 wrote:
> On Friday, September 27, 2013 10:09:24 AM UTC-5, dman777 wrote:
>
> > I am using Javascript Web Workers. In the web worker, I have:
>
> >
>
> >
>
> >
>
> > function makeRequestChat(id) {
>
> >
>
> > var jsonObj;
>
> >
>
> > var xml = new XMLHttpRequest();
>
> >
>
> > xml.open("POST", "/site/myapp/" + id, true);
>
> >
>
> > xml.onreadystatechange = function () {
>
> >
>
> > if (xml.readyState === 4 && xml.status === 200){
>
> >
>
> > var jsonObj = JSON.parse(xml.responseText, function (key,value) { parseChat(key, value, id); });
>
> >
>
> > var foo = chatQueues[id];
>
> >
>
> > foo.queue = id;
>
> >
>
> > var bar = JSON.stringify(foo);
>
> >
>
> > postMessage(bar);
>
> >
>
> >
>
> >
>
> > }
>
> >
>
> > }
>
> >
>
> > xml.send(null);
>
> >
>
> > }
>
> >
>
> > I am using copy for sending the json string. I get Uncaught Error: SyntaxError: DOM Exception 12 get.js:28 xml.onreadystatechange. This is specifically at postMessage(bar). This is strange there is nothing DOM related in this web workers code. I really need to get rid of this error if anyone can please help!
>
> >
>
> >
>
> >
>
> > Here is the json string being returned to main:
>
> >
>
> > "{"active":0,"unanswered":0,"available":3,"queue":"uk"}"
>
> >
>
> >
>
> >
>
> > I am desperate to get rid of this error if anyone can please help.
>
>
>
> Wow, interesting. Here is my main:
>
>
>
> var worker1 = new Worker("js/get.js");
>
>
>
> worker1.addEventListener("message", tell, false);
>
>
>
> worker1.postMessage();
>
>
>
>
>
> function tell(event) {
>
> var foo = JSON.parse(event.data);
>
> chatQelements(foo);
>
> }
>
>
>
>
>
> function chatQelements(foo) {
>
> var bar = document.getElementById("active" + foo["queue"]);
>
> bar.textContent = "Active: " + foo["active"];
>
> bar = document.getElementById("unans" + foo["queue"]);
>
> bar.textContent = "Unanswered: " + foo["unanswered"];
>
> bar = document.getElementById("avail" + foo["queue"]);
>
> bar.textContent = "Available: " + foo["available"];
>
> }
>
>
>
>
>
> How do I direct the workers postMessage(bar) to send the message to worker1.addEventListener("message", tell, false);?
Actually, the question is how do I keep it from going to the DOM window? I have verified that it goes to the worker1 object because the script works with the output I intended with the info from the message. I also verified in debugger that event.target = Worker. So I am not sure why the DOM Window is also accepting it and treating it like it goes to itself.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web