I`m working on a web application for Blockchain wallet, there I have a method that reads the live current balance of the wallet (from the blockchain). After the reading, I update some labeles that represents the balance (2 different coins type). The problem is that the update appears only when I refresh the page. Here is the function:
function updateAccountBalance()
{
var accountBalanceILS = @await Model.get_ILS_Balance(); //function in the Model
var accountBalanceETH = @await Model.get_ETH_Balance(); //function in the Model
document.getElementById("ilsBalance").innerHTML = "₪" + accountBalanceILS +" | ETH" ;
document.getElementById("ethBalance").innerHTML = "" + accountBalanceETH ;
} //just ignore how I use the innerHTML, believe me its working
The problem is because of the @await Model.get_ILS_Balance() and @await Model.get_ETH_Balance(). These functions require 'await'. If not I get null. But because of them, I cannot update the labels without refreshing the page.
I know they are the problem because of this example:
function updateAccountBalance()
{
var accountBalanceILS = 1234.2527; //example
var accountBalanceETH = 151542.2123 //example
document.getElementById("ilsBalance").innerHTML = "₪" + accountBalanceILS +" | ETH" ;
document.getElementById("ethBalance").innerHTML = "" + accountBalanceETH ;
} //If I just insert random number, it`s working
I would publish the functions get_ILS_Balance and get_ETH_Balance but I`m not sure it necessary. How can I overcome this problem and make the update without refreshing the page? If you require more information or more code please just let me know!!