Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
Dancer2::Plugin::Ajax(User Contributed Perl DocumentatDancer2::Plugin::Ajax(3)

NAME
       Dancer2::Plugin::Ajax - a plugin	for adding Ajax	route handlers

VERSION
       version 0.400000

SYNOPSIS
	   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 allows you to
       define a	route handler optimized	for Ajax queries.

       The route handler code will be compiled to behave like the following:

       o   Pass	if the request header X-Requested-With doesn't equal
	   XMLHttpRequest

       o   Disable the layout

       o   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".

       Here is an example to use JSON:

	 plugins:
	   Ajax:
	     content_type: 'application/json'

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.

perl v5.32.0			  2018-11-13	      Dancer2::Plugin::Ajax(3)

NAME | VERSION | SYNOPSIS | DESCRIPTION | CONFIGURATION | AUTHOR | COPYRIGHT AND LICENSE

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=Dancer2::Plugin::Ajax&sektion=3&manpath=FreeBSD+12.1-RELEASE+and+Ports>

home | help