Witam, próbuję napisać skrypt, który będzie pobierał ze strony liczbę kredytów, po to żeby użyć jej do konstrukcji ifa.
var poll = 141060;
var lottery = document.getElementById('inputlottery');
$.ajax({
url: 'coins.php',
cache: false,
success: function(html){
var coins = html;
document.getElementById('a').innerHTML = coins;
}
});
function processbet(){
if(lottery.value == 0 || lottery.value ==null){
bootbox.alert("You can't bet nothing in a lottery!");
}else if (lottery.value>poll) {
bootbox.alert("You can't bet higher than poll!");
}else if (lottery.value>coins) {
bootbox.alert("You can't bet higher than your balance!");
}
}
Użyłem
document.getElementById('a').innerHTML = coins;
Żeby sprawdzić czy $.ajax działa, i działa. Tylko że nie potrafię odczytać tej zmiennej z funkcji processbet.
else if (lottery.value>coins) {
bootbox.alert("You can't bet higher than your balance!");
}
Nie działa.
Bardzo proszę o pomoc, pozdrawiam.