On Mon, Apr 05, 2010 at 07:31:08PM +0200, Louis-David Mitterrand wrote: > Hi, > > I noticed this in "man HTML::Mason::Request": > > flush_buffer > [...] > Attempts to flush the buffers are ignored within the context of a > call to "$m->scomp" or when output is being stored in a scalar > reference, as with the " { store => \$out } " component call > modifier. > > I have been searching a long time why my javascript redirect was never > sent and finally understood why after reading this manual section. > > if ($r->headers_in->{'X-Requested-With'} eq 'XMLHttpRequest') { ## ajax > $r->warn("javascript redirect"); > $r->content_type("application/javascript"); > $m->print('window.location="/login.md";'); > $m->abort(200); > } > > This code is called within a component itself called with $m->scomp(). > > How can I make that work while still calling the compent with > $m->scomp()?
I found a solution: use $r->puts() instead of $r->print which is remapped by mason. $m->clear_buffer(); $r->content_type("application/javascript"); $r->puts('window.location="'.$url.'";'); $r->rflush; $m->abort(200); -- http://www.cruisefish.net ------------------------------------------------------------------------------ Sell apps to millions through the Intel(R) Atom(Tm) Developer Program Be part of this innovative community and reach millions of netbook users worldwide. Take advantage of special opportunities to increase revenue and speed time-to-market. Join now, and jumpstart your future. http://p.sf.net/sfu/intel-atom-d2d _______________________________________________ Mason-users mailing list Mason-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mason-users