in reply to Re: Loading values into template using Perl and Mojolicious::Lite
in thread Loading values into template using Perl and Mojolicious::Lite

Yes, you're right the first one works, but the second does not, I wonder if it has to do with the " return $->render(json => $data ); code.
  • Comment on Re^2: Loading values into template using Perl and Mojolicious::Lite
  • Download Code

Replies are listed 'Best First'.
Re^3: Loading values into template using Perl and Mojolicious::Lite
by Corion (Patriarch) on Mar 31, 2017 at 18:32 UTC

    You call ->render twice there. That doesn't make sense to me.

      I did, to try loading the template again, but there no need for that I realized. The "/get_status" route gets call by ajax once the page loads.Could that be the issue?
      # Load value into Main template, # but I cant get the results to display on the template. # $c->render( # template => 'main', # ); # this is the tag in the template <TMPL_VAR NAME="result"> $c->stash( result => ' This is the result for testing' ); # I also return json from the sql query results, which it was called + from ajax # and it works fine. return $c->render(json => $data );
      But it still doesn't work.

        I don't think that the stash will be included if you render JSON data.

        Put all your data into $data.

        Note that I don't use Mojolicious much, so I can only guess and read the documentation.