use strict; use warnings; use CGI qw(:standard); use JSON::XS; if ( request_method() eq "GET" ) { print header(-content_type => "text/html; charset=utf-8"), "This is not a human readable resource."; } elsif ( request_method() eq "POST" ) { # Open a file to save the POSTed info here! # Perhaps handle errors to return to Ajax. print header(-content_type => "application/json; charset=utf-8"), to_json( { status => "OK" } ); }