我有下面的jQuery ajax代码,并在页面滚动时调用ajax请求。现在,如果响应为空,我想停止发送新的Ajax请求。我不想执行Ajax代码,这有可能吗?
var eventPage = 2;
$(window).scroll(function() {
if ($(window).scrollTop() == $(document).height() - $(window).height()) {
$.ajax({
url: ajaxUrl,
type: 'post',
data: {
action: 'load_events_by_ajax',
page: eventPage,
security: '<?php echo wp_create_nonce("load_more_events"); ?>'
},
beforeSend: function() {
$('body').loading({
stoppable: true,
theme: 'dark'
});
},
success: function(response) {
$('body').loading('stop');
$('.EventThumbRow').append(response);
eventPage++;
},
error: function(xhr) {
$('body').loading('stop');
}
});
}
});
答案 0 :(得分:0)
使用布尔值 flag !
<?php
$term_fee = $this->db->get_where('fees' , array(
'student_id' => $row['student_code'], 'term' => $running_term,
'year' => $running_year ))->row()->fees;
echo $term_fee;
?>