Question

I'm trying to show a template in an AJAX route like this:

ajax '/login' => sub {
    my $user     = params->{uname};
    my $password = params->{upass};
    my $db_inst  = WebApp::Persistency::SQLiteDB->instance();

    if ($db_inst->is_user_registered($user,$password) == 1) {
        template "main_page";
    } else {
        return { res => 'Wrong' }; 
    }
};

The user indeed validates but the template never shows. When I use the template from a different route (non-ajax), it works.

Am I missing something here?

Was it helpful?

Solution

AJAX does not reload the whole page. How can you use a template if you are not reloading a page?

OTHER TIPS

A rendered template could be returned to the AJAX request and injected into the page.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top