我正在设置一台新服务器,并希望在不刷新整个页面的情况下自动扣除剩余余额。现在的问题是我必须刷新整个页面才能更新余额。
我已经搜索了有关jQuery的信息,但是我不知道如何使用它。
这是我的代码:
function updateRemaining(field_name, deduction) {
philhealth_deductions[field_name] = deduction;
var remaining = philhealth_budget;
for (var i in philhealth_deductions) {
remaining -= philhealth_deductions[i];
}
$("#remaining-philhealth span").html(remaining);
$(".philhealth_total").html(philhealth_budget-remaining);
}
function updateBalance(currentBalance) {
$("#remaining-philhealth-balance span").html(currentBalance);
}
我希望在不刷新页面的情况下更新余额。
答案 0 :(得分:0)
尝试一下
function updateRemaining(field_name, deduction) {
philhealth_deductions[field_name] = deduction;
var remaining = philhealth_budget;
for (var i in philhealth_deductions) {
remaining -= philhealth_deductions[i];
}
// give this id to your span "remaining-philhealth-span"
document.querySelector('#remaining-philhealth-span').innerHTML = remaining;
document.querySelector('.philhealth_total').innerHTML = philhealth_budget-remaining
updateBalance(remaining)
}
function updateBalance(currentBalance) {
// give this id to your span "remaining-philhealth-balance-span"
document.querySelector('#remaining-philhealth-balance-span').innerHTML = currentBalance
}