Hello,
I am a tad confused about ajax in K3.
Use case is a website which loads part of its content dynamically, while retaining other content unless there is a reload. The content in question would be one of several snippets, each fetching field content from actual and other pages, and possibly containing other snippets.
Being this a sort of SPA, would the API be the way to go? Then, as there is no user login, how to solve authentication? should I create a specific user for this and use basich https auth with it ?
Still I can’t see clearly how to deal with the API in my ase.
With k2 I had an api template with something like:
....
if(kirby()->request()->ajax()) {
$data[] = snippet($_POST["snippet"], array('p' => $_POST["page"] ), true);
echo json_encode($data);
}
...
…and I POSTed the snippet and page vars to that template, then placed the response data directly to the page with the likes of:
$(container).html(data);
But I see request ajax is deprecated and the api is built-in etc…
If this is already well explained, please direct me to the right docs, as I could not find them.
Thank you