Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

Example using ajax

Started by Muut Archive 11 years ago · 1 replies · 840 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 Deleted User, 9 years ago
0 2607 9 years ago
Archive · by Muut Archive, 9 years ago
2 1714 9 years ago
Archive · by Muut Archive, 9 years ago
2 5009 9 years ago
Archive · by Muut Archive, 9 years ago
1 3838 9 years ago
Archive · by Muut Archive, 9 years ago
3 1819 9 years ago