[Catalyst] Help understanding interaction with view; application using IE7 Prototype.js

Stephen Shorrock stephen.shorrock at googlemail.com
Fri Dec 21 11:58:07 GMT 2007


Dear List,

I wondered whether anyone could shed some light on what happens during the
flow of a request, there seems to be a difference in returning directly from
the controller and forwarding to a view.  This effect is show when using
Ajax.

This issue only appears in IE7, Firefox handles the response from the
request fine.

The situation is a s follows;

I have two javascript Updater methods in a page;
<html>
<head>
<script src=3D"/javascript/scriptaculous-js-1.8.0/lib/prototype.js"
type=3D"text/javascript"></script>
<script src=3D"/javascript/scriptaculous-js-1.8.0 /src/scriptaculous.js"
type=3D"text/javascript"></script>
</head>

<body>
....
<a  onclick=3D"  if ( Ajax.getTransport() ){ new
Ajax.Updater('securityInfo','/updater/timeMason',
{ evalScripts: true }); return false; }" href=3D"#testanchor">Method A</a>
<a  onclick=3D"  if ( Ajax.getTransport() ){ new
Ajax.Updater('securityInfo','/updater/time',
{ evalScripts: true }); return false; }" href=3D"#testanchor">Method B</a>

One of the ajax requests (Method A) calls a catalyst method that forwards to
a Mason view the other request (Method B) calls a catalyst method that
returns from the controller using: $c->response->body

the controllers;

Method A

sub timeMason : Local {
    my ($self, $c) =3D @_;

    $c->stash->{template} =3D 'updaterPages/timeMason.mhtml';
    $c->forward( $c->view('Mason') ) unless $c->response->body;
}

Method B

sub time : Local {
    my ($self, $c) =3D @_;

    $c->response->body("Updater ran @ ".localtime);
}

The mason page root/updaterPages/timeMason.mhtml contains :

 <% "Updater ran @ ".localtime %>


In IE7 when you run the controllers directly ie http://host/updater/time and
http://host/updater/timeMason the correct output is displayed, they both
work.

The problem is that in IE7, when run from the Javascript Updater, only
method B works the javascript fails when attempting to get the responseText
from the transport (in prototype.js line:  this.responseText =3D
String.interpret(transport.responseText ).  The examples I have seen using
AJAX with catalyst all seem to have the controller setting the response body
(method B).  Is it possible to use method A?

Thanks in advance

Stephen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20071221/81cb4=
329/attachment.htm


More information about the Catalyst mailing list