I'm new to jQuery, and I have been playing around with it a bit. I have one UI element called result, which is updated once the result arrives and this works perfectly. However, this result comes from a series of computations.
Now I want the UI element to update after each computation to show some sort of progress. However, if I set the value of the UI element inside this recursive function I'm using for computation, it doesn't update it.
Here's the code:
function getRes(val) {
if(val === finalVal)
return;
// do something
$("#result").text(someVal); //This doesn't work
getRes(val+1);
}
$("#resbtn").on('click', function(){
getRes(0);
$("#result").text(res); //This works
});
Why is this happening?