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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -