Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Archive

How to submit form without page refresh

Started by Muut Archive 10 years ago · 0 replies · 393 views
10 years ago

I've read the documentation, searched this forum and tried to learn from looking at the code of, as suggested, the Admin plugin but it's way over my head.
If I'm correctly, the 'trick' in Grav to prevent a page refresh is to have Twig return data as JSON. Can this be done by modifying the Form plugin? I tried changing the template data.txt.twigto detect the request type like so:
--- twig
{% if app.request.isXmlHttpRequest() %}
// code if ajax request
{% else %}
// code if not ajax request
{% endif %}

TXT

However, there seems to be more to it than that. Thanks in advance for suggestions and help on this.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1277 9 years ago
Archive · by Muut Archive, 9 years ago
2 885 9 years ago
Archive · by Muut Archive, 9 years ago
2 4014 9 years ago
Archive · by Muut Archive, 9 years ago
1 2891 9 years ago
Archive · by Muut Archive, 9 years ago
3 1074 9 years ago