I am having recursive function. it make calls every second. I want to kill that function in certain state.
function foo(){
// ajax call
//in ajax success
success: function(response){
setTimeout(function(){
foo();
},1000);
}
}
This code makes recursive call
if(user == "idile"){
//here i want to kill that foo() function
}
how can i do this ? Thanks in advance