[dancer-users] ajax plugin, serialize a 1D perl array to JSON

Anand Meher kvmsanand at gmail.com
Sun Jul 7 18:06:55 BST 2013


Thank you David and Rik for your answers,
                                                                I have one
more question, I tried executing some perl code from a ajax routine :
something like  :

*sub get_stats {*
*# some perl code goes here *
*  ## open a file using perl file open*
*  ## use dancer logger to output to console*
*  ## execute shell commands using system call of perl*
*}*
*
*
*ajax '/killprocess' => sub {*
*    get_stats;*
*
*
*};*
*
*
   But it seems that the perl code is not getting executed, I do not have
anything shown in my logger (console),
  am I doing something wrong over here ?

Thank You
\amk


On Sun, Jul 7, 2013 at 12:38 PM, David Precious <davidp at preshweb.co.uk>wrote:

> On Sat, 6 Jul 2013 17:59:21 -0700
> Rik Brown <rik at rikbrown.co.uk> wrote:
>
> > Of course you could also do:
> >
> > {
> >   results => \@sendArray
> > }
> >
> > if you want your output to be a hash at the top level.
> >
> > Hope this helps!
>
> Rik's answer above is the course of action I'd typically recommend
> - because even if you just want the array for now, in future you may
> well decide you want to provide other information from that call, too
> (perhaps be able to return an error message as a key named 'error', or
> return the number of results found as a key named 'count', or return
> the average of all the values... etc) - so returning a hashref as Rik
> illustrates helps with future-proofing, as you could easily add more
> information to the response without breaking existing code.
>
>
>
> --
> David Precious ("bigpresh") <davidp at preshweb.co.uk>
> http://www.preshweb.co.uk/     www.preshweb.co.uk/twitter
> www.preshweb.co.uk/linkedin    www.preshweb.co.uk/facebook
> www.preshweb.co.uk/cpan        www.preshweb.co.uk/github
>
>
> _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20130707/1cbb4816/attachment.htm>


More information about the dancer-users mailing list