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?
AJAX does not reload the whole page. How can you use a template if you are not reloading a page?