[dancer-users] How do I call a script from a template?
Andrew Beverley
andy at andybev.com
Thu Apr 30 19:49:37 BST 2015
On Wed, 2015-04-29 at 16:12 -0600, John J. McDermott, CPLP wrote:
>
> In a template I invoke (successfully) from a Dancer2 path I have some
> jquery that works outside Dancer2:
> $.post('/data1.pl',data,function(returnData){
> $('#func').html(returnData)
>
> This code calls data1.pl and stuff its output into the div func.
>
> I know data1.pl works in a non-Dancer2 environment. But I cannot
> figure out where to put data1.pl so it can be run from the template.
Surely the "correct" way of doing this is to rewrite data1.pl into your
main Dancer app, as its own route? Is there any reason that you cannot
do that?
> I tried just putting it in the dancer public (where the css folder,
> dispatch.cgi and such are), but that didn't work.
I would keep it out of there, as it's nothing to do with Dancer.
> I tried even to run it from the browser command line and the browser
> wants to download it. The directory has +ExecCGI and Dancer2 runs.
If you have to keep it separate to Dancer, then that's the way to do it.
Put it in a completely separate area of your web server, and ensure it
can be executed as its own independent script.
If the browser is trying to download it, then something is wrong with
your webserver configuration. I'm sure people will be happy to try and
assist, but that is not a Dancer problem, it is a generic web/perl
problem.
Andy
More information about the dancer-users
mailing list