realn0whereman has asked for the wisdom of the Perl Monks concerning the following question:

I have an array of values (objects actually) written in javascript. I am running my application via catalyst with the aid of template toolkit. I have a form sending email and some other stuff. <form method="post"  action=" [ % Catalyst.uri_for('/agg/submit')  % ] "> thats what the header of the form looks like. How do i get the data in the array to the catalyst backend?

Replies are listed 'Best First'.
Re: javascript through template toolkit to catalyst
by Anonymous Monk on Mar 29, 2009 at 03:48 UTC
    ...How do I get javascript data to catalyst backend?
    Through CGI
      Ok so i managed to do this without CGI. It's a bit ugly but it works. in my HTML file(technically my .tt2 file) i have this in my javascript area:
      for(m=0;m<selected.length;m++){ document.form.values.value += selected[m].name+','; }
      then I have this in my actual html area:
      <form method="post" name="form" action=" [% Catalyst.uri_for('/agg/su +bmit') %] "> <INPUT TYPE="hidden" NAME="values">
      and then in my catalyst controller ( which is agg.pm with submit as the method) :
      my $selected = $c->request->params->{values};
      from here i can parse the string into an array and proceed with my program.
        That is CGI!!!!
      I've been looking and I can't seem to understand how that would work. From what i've read, CGI is for getting perl data into html, and writing html with perl.