Sawyer X > Dancer2-0.140001 > Dancer2::Plugin::Ajax

Download:
Dancer2-0.140001.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.140001   Source   Latest Release: Dancer2-0.152000

NAME ^

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

VERSION ^

version 0.140001

SYNOPSIS ^

    package MyWebApp;

    use Dancer2;
    use Dancer2::Plugin::Ajax;

    # For GET / POST
    ajax '/check_for_update' => sub {
        # ... some Ajax code
    };

    # For all valid HTTP methods
    ajax ['get', 'post', ... ] => '/check_for_more' => sub {
        # ... some Ajax code
    };

    dance;

DESCRIPTION ^

The ajax keyword which is exported by this plugin allow you to define a route handler optimized for Ajax queries.

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

CONFIGURATION ^

By default the plugin will use a content-type of 'text/xml' but this can be overridden with plugin setting 'content_type'.

Here is example to use JSON:

  plugins:
    Ajax:
      content_type: 'application/json'

AUTHOR ^

Dancer Core Developers

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2014 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.

syntax highlighting: