Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

223
Visualizações
stop a running function on button click

my html file

<script>
    let socket = io();
    socket.on('update-value', function (value) { // When a 'update-value' event is received, execute the following code.
            console.log('received new value', value);

          //  $('#myname').html(value);
          $('#div1').prepend(value);

        });
        socket.on('checking-value', function (value) { // When a 'update-value' event is received, execute the following code.
            console.log('received new value', value);

            $('#name').prepend(value);

      
        });

        function searchStart() {
            socket.emit('searchStart')
            const button = document.querySelector('#startbtn')
            button.disabled = true
        }

        function searchStop() {
            socket.emit('searchStop', 1)
            const button = document.querySelector('#stopbtn')
            button.disabled = true
        }
    </script> 

server side js file

socket.on("searchStart", () => {

  runScript()
})

socket.on("searchStop", () => {

  // ??????????
})

the runScript function has a ton of for loops constantly fetching data and displaying em on the html page,

what i want is to make a stop button that stops all the ongoing for loops and data fetching "runScript function" from running on the server side untill i hit the start button again

about 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda