Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

222
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda