This is my code:
I based the window variable from here
<script>
$(window).on("load", function() {
function myForeverFunc(){
window.global_time = "3";
$.ajax({
url: "index.php?action=showReminder",
cache: false,
success: function(data){
if(data && data.charAt(0) === "1"){
window.global_time = "1";
}else{
console.log("test");
window.global_time = "2";
}
}
});
console.log(window.global_time);
}
setInterval(myForeverFunc, 60*1000);
});
</script>
This just displays "3" where it should have been updated to "2" in the else part of the ajax function.