{"id":2940,"date":"2014-03-11T09:31:34","date_gmt":"2014-03-11T09:31:34","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/11\/calling-postmessage-in-web-worker-onmessage-callback-throws-syntax_err-dom-exception-12-collection-of-common-programming-errors\/"},"modified":"2014-03-11T09:31:34","modified_gmt":"2014-03-11T09:31:34","slug":"calling-postmessage-in-web-worker-onmessage-callback-throws-syntax_err-dom-exception-12-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/11\/calling-postmessage-in-web-worker-onmessage-callback-throws-syntax_err-dom-exception-12-collection-of-common-programming-errors\/","title":{"rendered":"Calling postMessage in Web Worker onmessage callback throws SYNTAX_ERR: DOM Exception 12-Collection of common programming errors"},"content":{"rendered":"<p>When writing the onmessage callback for a Web Worker I get an &#8220;Uncaught Error: SYNTAX_ERR: DOM Exception 12&#8221; in my console when I try to send another postMessage().<\/p>\n<pre><code>var w = new Worker(url);\nw.onmessage = function(e) {\n    if(e.data.msg=='validate'){\n        if(validateWork(e.data.wrk)){\n            postMessage('proceed');\n        }\n    }\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>When writing the onmessage callback for a Web Worker I get an &#8220;Uncaught Error: SYNTAX_ERR: DOM Exception 12&#8221; in my console when I try to send another postMessage(). var w = new Worker(url); w.onmessage = function(e) { if(e.data.msg==&#8217;validate&#8217;){ if(validateWork(e.data.wrk)){ postMessage(&#8216;proceed&#8217;); } } }<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2940","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2940","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2940"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2940\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2940"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2940"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2940"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}