Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

221
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!