Real-time value for a variable

Asked

Viewed 281 times

0

Good morning guys I have the following code sending information to a script.

<!DOCTYPE html>
<html lang="pt">

<head>
    <meta charset="utf-8">
    <title>Javascript Example</title>
    <link rel="stylesheet" href="css/style.css">
</head>

<body>
    <label id="counter">0</label>
<script src="js/script.js"></script>
    <script src="js/jquery.min.js"></script>


    <script type="text/javascript">
        $(document).ready(function () {
            $.ajaxSetup({ cache: false });
            setInterval(function () {
                $.get("IOCounter.htm", function (result) {
                    $('#counter').text(result.trim());
                });
            }, 40);
        });

    </script>

    <button id='bot'> INICIAR TESTE </button>

<!--
    <div class='image-wrapper'>     
        <img src="img/aguard_teste.jpg" alt="">
    </div>-->

    <div id='pag-2' class='wait-test'>      
        AGUARDANDO TESTE
    </div>

    <div id='pag-1' class='wait-test'>      
        TESTANDO
    </div>


</body>
</html>

and sends the information to this script here

$('#bot').on('click', function(){
})

var i = 0;

setInterval( function () {
    $('#counter').text(i);
    i++;
    if ( i == 5.000000 ){
        $('#pag-1').show();
        $('#pag-2').hide();                     
    }
};

My doubt is how I do to take the information that is playing in the webcounter and send it to the scrip so when it arrives at a certain value I change a specific page that I am creating in the webserver in a CLP?

  • Your question is confused. Is the second script not in the same file as the first one? What do you mean by "sends information to a script". Your Ajax request is calling the IOCounter.htm. Is that second script in that file? That’s it?

  • this Iocounter is a file created for CLP to send the information, the second this script I created for it to compare the information played in html and when it reaches a certain number it gives me information on the screen

  • Both ajax and the second script are updating the label #counter. There is nothing comparing the value of it... It is not the case that the second script read what is in #counter instead of updating?

  • Friend managed to update but there was another doubt now I will post another question to be clearer

No answers

Browser other questions tagged

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