[Dancer-users] ajax plugin strangeness
Stephen Fenwick-Paul
stephen at activeg.org
Wed Oct 12 09:36:33 CEST 2011
I've experienced something similar.
If I have a Ajaxed request that fails due to a server error, then there is a
good chance that the page that the request was made from will, on the next
page refresh, l also be treated as though it is an ajax page, i.e. it will
lose its headers and footer etc.
My guess is that the ajax plug has some global variable that does not get
reset after a failed request. Sadly, I've not found a way
of consistently reproducing it.
I'm on apach2.
On Wed, Oct 12, 2011 at 1:57 AM, Puneet Kishor <punk.kish at gmail.com> wrote:
> Perhaps I don't understand how to correctly use the Dancer::Plugin::Ajax. I
> am running Dancer 1.3072 with Dancer::Plugin::Ajax running off of Starman
> proxies behind Apache2. I experience the following strangeness (which, you
> can test at http://humanesettlements.punkish.org)... Some Ajax queries
> (sent via jQuery) return as JSON, while others return as full html in spite
> of having identical headers. My server side code is
>
> ajax '/' => sub {
> my $page = params->{'page'} || 1;
> my $tags = params->{'tags'};
>
> my $res = query('page' => $page, 'tags' => $tags);
>
> return to_json \%res;
> };
>
> get '/' => sub {
> my $page = params->{'page'} || 1;
> my $tags = params->{'tags'};
>
> my $res = query('page' => $page, 'tags' => $tags);
> template "ideas", \%res;
> };
>
>
> Here are the queries as captured in the web debugger (in Safari). The
> following returned JSON
>
> • Request URL:http://humanesettlements.punkish.org/?tags=old_people
> • Request Method:GET
> • Status Code: 200 OK
> • Request Headers
> • Accept:application/json, text/javascript, */*; q=0.01
> • Referer:http://humanesettlements.punkish.org/
> • User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_1)
> AppleWebKit/534.48.3
> (KHTML, like Gecko) Version/5.1 Safari/534.48.3
> • X-Requested-With:XMLHttpRequest
> • Query String Parameters
> • tags:old_people
> • Response Headers
> • Connection:Keep-Alive
> • Content-Length:2905
> • Content-Type:text/xml; charset=utf-8
> • Date:Wed, 12 Oct 2011 00:42:29 GMT
> • Keep-Alive:timeout=5, max=99
> • Server:Perl Dancer 1.3072
> • X-Powered-By:Perl Dancer 1.3072
>
> JSON response (snipped): {"prev_str":"..}
>
> The following failed in that it returned full HTML content in spite of
> sending the correct revue headers
>
> • Request URL:
> http://humanesettlements.punkish.org/?tags=old_people+implementation
> • Request Method:GET
> • Status Code: 200 OK
> • Request Headersview source
> • Accept:application/json, text/javascript, */*; q=0.01
> • Referer:
> http://humanesettlements.punkish.org/?tags=old_people
> • User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_1)
> AppleWebKit/534.48.3
> (KHTML, like Gecko) Version/5.1 Safari/534.48.3
> • X-Requested-With:XMLHttpRequest
> • Query String Parametersview URL encoded
> • tags:old_people implementation
> • Response Headersview source
> • Connection:Keep-Alive
> • Content-Length:21176
> • Content-Type:text/xml; charset=utf-8
> • Date:Wed, 12 Oct 2011 00:42:37 GMT
> • Keep-Alive:timeout=5, max=100
> • Server:Perl Dancer 1.3072
> • X-Powered-By:Perl Dancer 1.3072
>
> HTML response (snipped): <!doctype html>
>
> <!--
> hacked by Puneet Kishor, based on HTML Boilerplate by Paul
> Irish and Divya Manian
> all modifications released under a CC0 waiver by Puneet
> Kishor
> March 15, 2011
>
> See http://html5boilerplate.com/ for the original
> -->
>
> _______________________________________________
> Dancer-users mailing list
> Dancer-users at perldancer.org
> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.backup-manager.org/pipermail/dancer-users/attachments/20111012/26c1ea09/attachment.htm>
More information about the Dancer-users
mailing list