conditional - Javascript: " != " Operator doesn't work properly -



conditional - Javascript: " != " Operator doesn't work properly -

good eve !

i facing unusual behavior js/jquery, simple function retrieving lastly id of row, in order check wether or not it's different previous one:

class="snippet-code-js lang-js prettyprint-override">oldmsgid = 0; // ajax... currentid = $( ".message_container tr:last" ).attr('id'); checknewmsg(currentid); // ... end ajax. function checknewmsg(msgid) { if (msgid != oldmsgid) { var snd_msg = new audio('sound/msg.wav'); snd_msg.volume = 0.3; snd_msg.play(); } oldmsgid = msgid ; }

the scheme works, however, when no new messages retrieved, means latest id equal old id, still execute status !

of course, execute 1 time page loaded because oldmsgid set 0, after testing alerts, has shown status running should not !

it drives me crazy, if has solution glad hear :)

edit : resolved

well, while using alerts within function time, appears have made huge error placing oldmsgid var within loop function (which calls ajax), so, variable reset 0 everytime , made difference, i'm sorry xd!

problem resolved, !

well, while viewing alerts within function time, appears have made huge error placing oldmsgid var within loop function (which calls ajax), i'm sorry xd!

problem resolved, !

javascript conditional operator-keyword behavior

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -