I have two functions in Javascript, one waits for first execution of a button and waits for second button to fire when it reads first value(field8=0) and continue to second value(field8=1). But the problem i want a way to stop iteration, the iteration continues without stopping. How do i read first value as being 0 and vice versa? Be able to show status message to a user if that value is 0 or 1? So that when it finds it continue until it stop iteration process in Ajax/Javascript. Please help, thanks.
What I have tried:
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
function Subscribe() {
$.ajax({
url:'https://api.thingspeak.com/update?api_key=***&field8=0',
type:'GET',
data:{
type:'text'
},
success:function(response){
alert(response);
$('#singlebutton').append(data);
}
});
setTimeout("Subscribe()", 100);
}
function UnSubscribe() {
$.ajax({
url:'https://api.thingspeak.com/update?api_key=***&field8=1',
type:'GET',
data:{
type:'text'
},
success:function(response){
alert(response);
$('#singlebtn').append(data);
}
});
}
</script>