Dancer...n::Ajax(3pm)
Dancer2::Plugin::Ajax(3pm) β a plugin for adding Ajax route handlers π
okay bestie, so this is the manual page for Dancer2::Plugin::Ajax, straight outta the User Contributed Perl Documentation (the header on this page literally prints it as Dancer...n::Ajax(3pm), iykyk β the terminal just clips the long name). It's a Perl plugin, it's giving main character energy, and it's about to make your Ajax routes so much less annoying. π¦
β¨ VERSION β¨
version 0.400000 π
β¨ SYNOPSIS β¨
no cap, this is the whole vibe in one code block:
package MyWebApp;
use Dancer2;
use Dancer2::Plugin::Ajax;
# For GET / POST
ajax '/check_for_update' => sub {
my $self = shift;
# ... some Ajax code
};
# For all valid HTTP methods
ajax ['get', 'post', ... ] => '/check_for_more' => sub {
my $self = shift;
# ... some Ajax code
};
dance;
β¨ DESCRIPTION β¨
The ajax keyword, which is exported by this plugin (yes, it just hands you ajax, no extra work π), lets you define a route handler that's been optimized for Ajax queries. Obsessed, honestly.
The route handler code will be compiled to behave like the following:
- Pass if the request header
X-Requested-Withdoesn't equalXMLHttpRequestπ - Disable the layout (no layout for you, bestie)
- The action built matches POST / GET requests by default. This can be extended by passing it an ArrayRef of allowed HTTP methods.
The route handler gets the Dancer $self object passed in, just like any other Dancer2 route handler. You can use this to inspect the request data. π
ajax '/check_for_update' => sub {
my $self = shift;
my $method = $self->app->request->method;
# ...
}
β¨ CONFIGURATION β¨
By default the plugin will use a content-type of 'text/xml', but this can be overridden with the plugin setting "content_type". Literally that easy.
Here is an example to use JSON:
plugins:
Ajax:
content_type: 'application/json'
slay. π
β¨ AUTHOR β¨
Dancer Core Developers π
β¨ COPYRIGHT AND LICENSE β¨
This software is copyright (c) 2016 by Alexis Sukrieh.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. π«Ά
and that's the whole page, bestie! π this one's from perl v5.36.0, dated 2022-12-12, and it lives in the User Contributed Perl Documentation section. go build something iconic with it. periodt. π
β¨πΈ
π¦ where this page comes from
- debian bookworm: libdancer2-plugin-ajax-perl 0.400000-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libdancer2-plugin-ajax-perl 0.400000-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libdancer2-plugin-ajax-perl 0.400000-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libdancer2-plugin-ajax-perl 0.400000-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libdancer2-plugin-ajax-perl 0.400000-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms