Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

Example using ajax

Started by Muut Archive 11 years ago · 1 replies · 887 views
11 years ago

Could you please give me an example how to use ajax in grav ?

I'm able to send a GET request with jquery to a page, but i don't know where to put the logic for its processing, and i need write the code in php or twig ?

Thanks !

11 years ago

I assume you'd like the URL you call to "do something" or to return some json values. You need to write a plugin that listens on a URL and returns some results.

https://github.com/flaviocopes/grav-plugin-api is a example (draft) of a plugin that provides an API. You can see how that is built, and create your own plugin.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Muut Archive, 10 years ago
1 674 1 week ago
Archive · by Deleted User, 9 years ago
0 3043 9 years ago
Archive · by Muut Archive, 9 years ago
2 1983 9 years ago
Archive · by Muut Archive, 9 years ago
2 5337 9 years ago
Archive · by Muut Archive, 9 years ago
1 4134 9 years ago