Async reload of a view with pagination

hello folks,

trying to re-render a paginated partial view with an Ajax call

public function loadMore(): void
    {
        self::checkAjaxReferer();
        $page = isset($_POST['page']) ? intval($_POST['page']) : 1;
        $composer = new Homepage();
        $data = $composer->griglia($page); 

//$data['items'] have data
            echo view('components.griglia-hp', ['item' => $item])->render();
    }

Homepage.php:

protected static $views = [
        'homepage',
        'components.griglia-hp',
    ];

...

public function griglia(int $page = 1): array
    {
        $fascia = [];
        $items_per_page = 6;
        $start_index = ($page - 1) * $items_per_page;
        $end_index = $start_index + $items_per_page;
....

the very first run at homepage load is fine, but if I try to load more
by appending them via Ajax:

...
success: function(response) {
      console.log(response); // Add this for debug
        $('#griglia').append(response);
...

only return “0” :confused:

Please read How to best ask questions on this forum

Provide a minimum reproducible example
Demonstrate your issue with a list of instructions that can be followed to replicate it.