Hi Jason,

No, nothing there...I'll try to make a simple testcase.

Thanks

Roland

 

From: Jason Galea [mailto:li...@eightdegrees.com.au] 
Sent: 27 April 2012 13:29
To: The elegant MVC web framework
Subject: Re: [Catalyst] TT via AJAX

 

Hi Roland,

 

you shouldn't need to forward to a JSON view. Calling the status_ok method 
should set up the response and return the serialized data. Is there anything 
showing in the error logs? What client are you using to test?

 

there isn't really a space between "sub ajaxaction" & "_GET {" in your source 
is there?

 

J

On Fri, Apr 27, 2012 at 9:54 PM, Roland Philibert <rphilib...@aptina.com> wrote:

Hi Jason,

 

My ajax action are already set as you say. 

I still need to forward to a JSON view, which was in my "end" action. If I dont 
forward it, I don't get anything back at the client..but if I do then back to 
square one..

 

 

From: Jason Galea [mailto:li...@eightdegrees.com.au] 
Sent: 27 April 2012 02:52


To: The elegant MVC web framework
Subject: Re: [Catalyst] TT via AJAX

 

 

On Fri, Apr 27, 2012 at 12:03 AM, Roland Philibert <rphilib...@aptina.com> 
wrote:

If I remove the end action and wite $body in the log, I do get what I want (ie 
rendered html from my TT with its "result" variable).

...so your conclusion about not serializing the @content seems to be on the 
right track. 
...is this liked to what Will has suggested to get around this issue? What do 
you suggest I do next?

 

well, now a GET request to your ajaxaction action (with content-type 
"application/json") should return the request body containing a json array with 
the first (and only) element being your html.

 

         

        Thanks

        R.

         

        From: Jason Galea [mailto:li...@eightdegrees.com.au] 
        Sent: 26 April 2012 14:32

        
        To: The elegant MVC web framework
        Subject: Re: [Catalyst] TT via AJAX

         

         

        Hi Roland,

         

        On Wed, Apr 25, 2012 at 11:26 PM, Roland Philibert 
<rphilib...@aptina.com> wrote:

        Hello all,

        I'd like to render some HTML content being formatted from a  TT view 
via AJAX.
        Can anybody recommend a way to do that please?

         

        The method I am using now for AJAX  is REST controller and JSON View.

         

        ...

        sub ajaxaction :Local :ActionClass('REST') {}

         

        sub ajaxaction _GET {

         

                        my ($self, $c) = @_;

                        my $rs =  $c->model(DN)->resultset(Table)->find(...);

                        my $body = 
$c->view(MYTT)->render($c,'dir/temp.mailtt',$c->stash( result  => [ $rs ] )); ß 
this is the weird bit I guess.

                        my @content =();

                        push @content, $body;

                        $self->status_ok(

                                $c,

                                entity => \@content,

                        );

        }

        sub end :Private {

                my ($self, $c) = @_;

                $c->forward("View::JSON");

        }

         

        ..but doing this I get the error:

         

        Caught exception in MyApp::View::JSON->process "encountered object 
'MyApp::Model::DB::Table=HASH(0xdb2c330)', but neither allow_blessed nor 
convert_blessed settings are enabled at (eval 1606) line 151."

         

        have you tried this without the 'end' action?

         

        What is MyApp::View::JSON trying to serialize? or what module are you 
subclassing?

         

        Looks to me like $body should be what you think it is (have you 
confirmed that?) but I don't think  MyApp::View::JSON is serializing your 
content array, but instead is attempting to serialize the "result" in your 
stash.

         

        cheers,

         

        J

         

                 

                Thanks for your help.

                Roland

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                Aptina (UK) Limited, Century Court, Millennium Way, Bracknell, 
Berkshire, RG12 2XT. Registered in England No. 06570543.
                 
                This e-mail and any attachments contain confidential 
information and are solely for the review and use of the intended recipient. If 
you have received this e-mail in error, please notify the sender and destroy 
this e-mail and any copies.
                 

                
                _______________________________________________
                List: Catalyst@lists.scsys.co.uk
                Listinfo: 
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
                Searchable archive: 
http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
                Dev site: http://dev.catalyst.perl.org/

         

        Aptina (UK) Limited, Century Court, Millennium Way, Bracknell, 
Berkshire, RG12 2XT. Registered in England No. 06570543.
         
        This e-mail and any attachments contain confidential information and 
are solely for the review and use of the intended recipient. If you have 
received this e-mail in error, please notify the sender and destroy this e-mail 
and any copies.
         

        
        _______________________________________________
        List: Catalyst@lists.scsys.co.uk
        Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
        Searchable archive: 
http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
        Dev site: http://dev.catalyst.perl.org/

 

Aptina (UK) Limited, Century Court, Millennium Way, Bracknell, Berkshire, RG12 
2XT. Registered in England No. 06570543.
 
This e-mail and any attachments contain confidential information and are solely 
for the review and use of the intended recipient. If you have received this 
e-mail in error, please notify the sender and destroy this e-mail and any 
copies.
 


_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

 


Aptina (UK) Limited, Century Court, Millennium Way, Bracknell, Berkshire, RG12 
2XT. Registered in England No. 06570543.

This e-mail and any attachments contain confidential information and are solely 
for the review and use of the intended recipient. If you have received this 
e-mail in error, please notify the sender and destroy this e-mail and any 
copies.

_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Reply via email to