Why does this not work? Can anyone explain this to me?
t = setInterval(refresh_div,100);
function refresh_div2() {
jQuery.ajax({
url:'livesatoshi.php',
type:'POST',
success:function(results2) {
jQuery(".satoshi").html(results2).tofixed(2);
}
});
}
The function name is not correct and the toFixed function needs to be corrected , as below :-
t = setInterval(refresh_div2(),100);
success:function(results2){
jQuery(".satoshi").html(results2.toFixed(2));
}
Put the above code in proper place and you will get your desired result .
toFixed() is case sensitive and is only a prototype function for Number data types. results2 is likely not a Number type at this point, so you'll need to convert it to one with Number.parseFloat()
.
Assuming you want the value of results2 as a number with 2 decimal points, you'll want to use:
Number.parseFloat(results2).toFixed(2); // returns "###.##" as a string