Do a Jquery conditional test?

Asked

Viewed 211 times

0

I am making a page and I need it updated constantly, but only when the value of an external page I called with the Jquery.get() function is different from the one already contained in the file, it follows my jquery code...

$(document).ready(function() {
    setInterval(function()
    {
        $.ajaxSetup ({ cache: false });
        $.get("config-stream.php?pegar=musica-atual", function(verifica){

            var musicaAtual = $("#tudo").text();        
            if(verifica != musicaAtual){
                $("#tudo").html(verifica);
            }
        });
    }, 2000);
});

And the related HTML...

<div id="tudo">
    valorinicial
</div>
<p id="oi"></p>
  • I don’t understand your problem? What’s not working?

  • When I use the condition structure does not return me results

  • what gives console.log(musicaAtual, verifica); before the line that has the if?

  • It wouldn’t be better to use stream Events ¿

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.