tags:

views:

1214

answers:

2

I'm trying to figure out why I'm not seeing params with $.post("/url/", {wtf: 2}).

I'm using this perl:

use strict;
use CGI;

my $cgi = new CGI;
print $cgi->header("text/javascript");
print "'no'";

use Data::Dumper;
warn Dumper({ (map {$_=>$cgi->param($_ )} $cgi->param), postdata=>$cgi->param("POSTDATA") });

When I issue a $.get("/url", {wtf: 2}), I get the results I expect and find wtf is 2 in the logs. When I use $.post("/url/", {wtf: 2}), I don't seem to get any params at all (just a $VAR1 = { postdata=>undef } in the logs).

What am I missing?

Firebug reveals that: Transfer-Encoding is "chunked" and Content-Type is "application/x-www-form-urlencoded; charset=UTF-8". Further, the Post tab seems to show the arguments in the request, but no joy from CGI.

+3  A: 

Could be that your results are coming back neither application/x-www-form-urlencoded nor multipart/form-data. CGI doc has this to say about it:

If POSTed data is not of type application/x-www-form-urlencoded or multipart/form-data, then the POSTed data will not be processed, but instead be returned as-is in a parameter named POSTDATA. To retrieve it, use code like this:

    my $data = $query->param('POSTDATA');
Axeman
POSTDATA seems to be empty also.
jettero
Axeman
+1  A: 

If you've got access to a linux box, you could set up 'nc' (netcat) to listen on port 80 and see the raw requests you're receiving.

I suspect it's a server-side problem though. Perhaps some Apache configuration is interfering? Sorry I can't be more help.

aidan