How can I get a variable in my javascript function to update every time the script is ran? The variable grabs a PHP string, which it then seems it stores it and doesn't update the value ever till a page refresh is done.
SCRIPT:
setInterval(function () {
var options = {
useEasing : true,
useGrouping : true,
separator : ',',
decimal : '.',
};
var value123 = <?php echo $amount22; ?>;
var value234 = <?php echo $unpaidbtc; ?>;
var demo = new CountUp("counter", value123, value234, 10, 1, options);
demo.start();
}, 5000);
Basically it grabs the $unpaidbtc value for my php in the page. This script will run every 5 seconds, but instead of updating with the new value the php has, it uses the first value it grabbed and never updates to the new PHP string.
Is there anyway to make the script update and re grab the PHP script from the page automatically?
Example: $unpaidbtc = 10 on start and $unpaidbtc = 15 after 5 seconds, but counter only goes up to 10. How can it grab the new value without refreshing the page and stuff, thanks!