Return-Path: X-Original-To: apmail-perl-embperl-archive@www.apache.org Delivered-To: apmail-perl-embperl-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 62C2C1771E for ; Thu, 2 Apr 2015 11:46:49 +0000 (UTC) Received: (qmail 11127 invoked by uid 500); 2 Apr 2015 11:46:49 -0000 Delivered-To: apmail-perl-embperl-archive@perl.apache.org Received: (qmail 11107 invoked by uid 500); 2 Apr 2015 11:46:49 -0000 Mailing-List: contact embperl-help@perl.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list embperl@perl.apache.org Received: (qmail 11097 invoked by uid 99); 2 Apr 2015 11:46:49 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Apr 2015 11:46:49 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW X-Spam-Check-By: apache.org Received-SPF: unknown (athena.apache.org: error in processing during lookup of f.wesemann@fotofinder.com) Received: from [209.85.215.46] (HELO mail-la0-f46.google.com) (209.85.215.46) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Apr 2015 11:46:45 +0000 Received: by lahf3 with SMTP id f3so57454592lah.2 for ; Thu, 02 Apr 2015 04:44:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=nQkWghFo7RDknqSHSuVaU7nhNmjxTYdJuOyEbLT8YXU=; b=dcucFHWnwr4n36L09Ge2mqyCqV7OA4fBC+COrk0jOpDBH7vkkM8AsG/wXGdgBmfqN1 /yKcIux5bWvsHoesbovzzliIJp+b/vrDmzYX6BSNMndMbxicNU/M0tQdYSL4rcB3l0z7 u+buly9P+jhoCwfPtNyewFEGiLbNDXPqNtYIcBn5IUhA/+WJvWN7MUIUo1rBkNb0Rpbm 2MVVwNfqOddBsGaKOPF6QcM8XQ5bIQKRJjCj9Y7m8bCla3irhq9apEXim6LQrOGl3goF iGH145N8wE+8FmOb2j9ZujTGgPCB3CMPR6cDrC2ExC1SgCZ6q6DZwIts07aJ/ZQBQSfc BmkQ== X-Gm-Message-State: ALoCoQkHmhyLgIq0r7zPuv9B3tGvDieQ4KsfYI3Z5SWoqAfPXJLcP5W9MKSsQgGaanzRxGd2AadR MIME-Version: 1.0 X-Received: by 10.112.44.132 with SMTP id e4mr40591064lbm.66.1427975091963; Thu, 02 Apr 2015 04:44:51 -0700 (PDT) Received: by 10.152.2.137 with HTTP; Thu, 2 Apr 2015 04:44:51 -0700 (PDT) In-Reply-To: <551980B3.9070205@mycopanet.com> References: <551980B3.9070205@mycopanet.com> Date: Thu, 2 Apr 2015 13:44:51 +0200 Message-ID: Subject: Re: embperl and JSON From: Frank Wesemann To: Donavon Cc: embperl@perl.apache.org Content-Type: multipart/alternative; boundary=001a11343f761ade7a0512bc5c26 X-Virus-Checked: Checked by ClamAV on apache.org --001a11343f761ade7a0512bc5c26 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable This is more a problem of CGI.pm ( which Embperl uses under the hood ). http://stackoverflow.com/questions/19610312/perl-cgi-passing-variable-in-po= st-with-json may help you. 2015-03-30 18:58 GMT+02:00 Donavon : > 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} =3D "test"; > $json =3D encode_json(\%fdat); > > $escmode =3D 0; > $http_headers_out{'Content-Type'} =3D "application/json; > charset=3Dutf-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 > > --=20 --=20 mit freundlichem Gru=C3=9F, Frank Wesemann Fotofinder GmbH USt-IdNr. DE812854514 Software Entwicklung Web: http://www.fotofinder.com/ Potsdamer Str. 96 Tel: +49 30 25 79 28 90 10785 Berlin Fax: +49 30 25 79 28 999 Sitz: Berlin Amtsgericht Berlin Charlottenburg (HRB 73099) Gesch=C3=A4ftsf=C3=BChrer: Ali Paczensky --001a11343f761ade7a0512bc5c26 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
This is more a problem of CGI.pm ( which Embperl uses unde= r the hood ).
m= ay help you.

2015-03-30 18:58 GMT+02:00 Donavon <donl@mycopanet.com>:
Hello.

I am creating an ajax call to an embperl script and I need assistance in ge= tting the script to work with json data sent with "application/json&qu= ot;

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

It doesn't work when I send data via javascript with:
=C2=A0 request.setRequestHeader("Content-Type", "appl= ication/json");
=C2=A0 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}=C2=A0 =3D "test";
$json=C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D encode_json(\%fdat);

$escmode =3D 0;
$http_headers_out{'Content-Type'}=C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0=3D "application/json; charset=3Dutf-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




--
--=C2=A0
mit freundlichem Gru=C3=9F,

Frank Wesemann
Fotofinder GmbH =C2=A0 =C2=A0 =C2=A0 = =C2=A0 USt-IdNr. DE812854514
Software Entwicklung =C2=A0 =C2=A0Web:= =C2=A0http://www.fotofinder.com/
Potsdamer Str. 96 = =C2=A0 =C2=A0 =C2=A0 Tel:=C2=A0+49 30 25 79 28 90
10785 Berlin =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0Fax:=C2=A0+49 30 25 79 28 999

Sitz: Berlin
Amtsgericht Berlin Charlottenburg (HRB 7309= 9)
Gesch=C3=A4ftsf=C3=BChrer: Ali Paczensky
--001a11343f761ade7a0512bc5c26--