javascript - Nested function not work in Mozilla browser -
i have call below function in application
function workercall() { debugger; if (typeof (worker) !== "undefined") { var worker = new worker("scripts/worker.js"); worker.onmessage = workerresultreceiver; worker.onerror = workererrorreceiver; worker.postmessage({ 'username': username }); function workerresultreceiver(e) { $('.notificationcount').html(e.data); if (parseint(e.data) != 0 && currentpage == "alert") { stateflag = false; $('.notification').show(); $('.drildown').each(function () { var temp = this.id; if ($('#' + temp).attr('expand') == "true") { currenttab = temp; stateflag = true; } }); currentscrollposition = $('body').scrolltop(); getalerts(); } else { $('.notification').hide(); } } function workererrorreceiver(e) { console.log("there problem webworker within " + e); } } else { } }
the method execute in ie,chrome when comes mozilla got error referenceerror: workerresultreceiver not defined.how can resolve error?
this happens because making reference function not created yet. need put this:
worker.onmessage = workerresultreceiver; worker.onerror = workererrorreceiver;
above
function workererrorreceiver
line or @ end of scope.
Comments
Post a Comment