Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^8: json return value

by stenasc (Novice)
on Jul 16, 2013 at 07:50 UTC ( #1044527=note: print w/ replies, xml ) Need Help??


in reply to Re^7: json return value
in thread json return value

I wish !! Big fat error...

Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, webmaster@myurl.com and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Very tired and pissed off with this issue at this stage. Must be something fundamental wrong with the server.


Comment on Re^8: json return value
Re^9: json return value
by Corion (Pope) on Jul 16, 2013 at 07:53 UTC

    Again, see Re^7: json return value. The web server error log likely contains more information.

    The error message even says so.

Re^9: json return value
by poj (Curate) on Jul 16, 2013 at 08:31 UTC
    Ok, take a step back, try this simple script
    #!/usr/bin/env perl use strict; use warnings; use CGI; use CGI::Carp('fatalsToBrowser'); use JSON; my $q = CGI->new; print $q->header(), $q->start_html(-title=>"Hello World"), $q->h2("Hello World"), $q->end_html();
    I noticed on first line of your cgi that worked you had #!/usr/bin/perl. If this script doesn't work try changing that.
    poj

      Same thing when accessed through browser

      Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, webmaster@tyder.com and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

      Server log is...

      16/Jul/2013:13:14:25 +0100 "GET /cgi-bin/test2.cgi HTTP/1.1" 404 - "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)"

      That worked, but need a slight change...

      #!/usr/bin/env perl use strict; use warnings; use CGI; use CGI::Carp('fatalsToBrowser'); use JSON::PP(); my $q = CGI->new; print $q->header(), $q->start_html(-title=>"Hello World"), $q->h2("Hello World"), $q->end_html();
        Ok so try again with JSON::PP
        #!/usr/bin/env perl use strict; use warnings; use CGI (); use JSON::PP (); my $q = CGI->new; my $data = $q->param('POSTDATA') || '{"a":100,"b":300}'; my $json = JSON::PP->new->utf8; my $input = $json->decode( $data ); my $a = $input->{a}; my $b = $input->{b}; my $c = $a + $b; print $q->header("application/json"); print $json->encode({ c => $c });
        poj

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1044527]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (15)
As of 2014-08-01 16:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (32 votes), past polls