perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Donavon <d...@mycopanet.com>
Subject embperl and JSON
Date Mon, 30 Mar 2015 16:58:27 GMT
Hello.

I am creating an ajax call to an embperl script and I need assistance in 
getting the script to work with json data sent with "application/json"

It works when I send data via javascript with:
   request.setRequestHeader("Content-Type", 
"application/x-www-form-urlencoded");
   request.send(encodeURLQueryString(data));

It doesn't work when I send data via javascript with:
   request.setRequestHeader("Content-Type", "application/json");
   request.send(JSON.stringify(data));


My submit form looks like this:

submit.epl
[-
use JSON; # imports encode_json, decode_json, to_json and from_json.

$fdat{test}  = "test";
$json        = encode_json(\%fdat);

$escmode = 0;
$http_headers_out{'Content-Type'}         = "application/json; 
charset=utf-8";
print OUT $json;
-]


Thank You,
~Donavon

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Mime
View raw message