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