我在这里想念什么?我的jquery函数未触发。这是HTML:
<div id="sum_income" class="col-sm-3" onload="sumIncome();">
</div>
这是jquery函数:
function sumIncome() {
var cur_month = $('#month option:selected').attr("value");
$.ajax({
type: "POST",
url: 'inc/functions.php',
data: {action: "get_sum_income", cur_month:cur_month},
success: function(response){
$('#sum_income').html(response);
setTimeout(sumIncome, 5000);
}
})
};
更改您的jquery代码。
$(document).ready(function(){
if($("#sum_income").length){
var cur_month = $('#month option:selected').attr("value");
$.ajax({
type: "POST",
url: 'inc/functions.php',
data: {action: "get_sum_income", cur_month:cur_month},
success: function(response){
$('#sum_income').html(response);
setTimeout(sumIncome, 5000);
}
})
}
});
这将明确地工作
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句