0

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?

spazm
  • 4,399
  • 31
  • 30
snoofkin
  • 8,725
  • 14
  • 49
  • 86

2 Answers2

1

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

choroba
  • 231,213
  • 25
  • 204
  • 289
1

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

Tyler Neu
  • 11
  • 1