Suggestion search and partial ajax page load

Hi, everybody!
Is it possible to do a suggestion search and partial page load with Kirby CMS?
Maybe you know some plugins or technics to do this.
Thank you!

https://getkirby.com/docs/cheatsheet/site/search as search() returns a $pages-Object you can do something like this in your template/search.php (this should be on top of the file, before any other output):

if(kirby()->request()->ajax()) {
    $results = $site->search(get('q'));
    return $results->toJson();

    die();
}

Now you can send a ajax request to yousite.com/search?q=whatever and probably pass that to some fancy jQuery Plugin (after mapping the results).

1 Like

Ok, Thank you!
And what about a page load, without browser refresh? Do you know some method?

As @Pascalmh said, you will need JavaScript code in the frontend that sends an AJAX request to the server to get the information. Browsers can do that natively (XMLHttpRequest), but if you have never done this before, you can use something like jQuery.get().