我想这样可能行得通,如果response
仅为HTML并返回空字符串\'\'
当没有更多结果时:
<script type="text/javascript">
var ajaxurl = "<?php echo admin_url( \'admin-ajax.php\' ); ?>";
var page = 2;
jQuery(function($) {
$(\'body\').on(\'click\', \'.loadmorefollowing\', function() {
var data =
{
\'action\': \'user_following_by_ajax\',
\'page\': page,
\'security\': \'<?php echo wp_create_nonce("user_more_following"); ?>\',
\'author\': \'<?php echo esc_html($curauth->ID); ?>\'
};
$.post(ajaxurl, data, function(response) {
if ( \'\' === response ) {
$(\'.loadmorefollowing\').hide();
return;
}
$(\'#following-artists-cont\').append(response);
page++;
});
});
});
</script>