[Dancer-users] how to remove preformated text
David Precious
davidp at preshweb.co.uk
Tue Sep 4 23:46:45 CEST 2012
On Tue, 4 Sep 2012 21:41:55 +0000
Sigis Dagilis <sigidagi at hotmail.com> wrote:
>
>
>
> I've wrote in the module:
What module? Your Dancer app?
> print $callback . '(' . $json . ');
If that's in a route handler, you want to return the content to be
passed to the user's browser, not print it.
>
> and I've got 'dancer'respond on a browser:
>
> somfunc({
> "items" : [
> "a",
> "b",
> "c",
> "d"
> ]
> }
> );HTTP/1.0 200 OK
> Server: Perl Dancer 1.3099
> Content-Length: 1
> Content-Type: text/html; charset=utf-8
> X-Powered-By: Perl Dancer 1.3099
>
> 1
That's.... weird.
Anyway, change your route handler to return the content instead of
calling print:
get '/foo' => sub {
return "$callback($json);";
};
... and all should be well.
(The reason the response had a Content-Length of "1", and consisted of
just "1", was because your route handler was returning the result of
the print call as the response content.)
> just a begginer
Welcome to the Dancer community :)
--
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
More information about the Dancer-users
mailing list