Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Here is a simple Perl script to read the data sent I am trying:<script type="text/javascript" > $(function() { $(".submit").click(function() { var formData = $("#reply-form").serialize(); alert(formData); $.ajax({ type: "post", url: "code.pl?test=test", cache: false, data: formData, contentType: "application/json; charset=UTF-8", dataType: "json", success: function(data) //onSuccess, { alert(data); }, error: function(xhr, ajaxOptions, thrownError) { console.log('status: ' + xhr.status); console.log('thrownError:' + thrownError); } }); }); // return false to prevent normal browser submit and page navigation return false; }); </script>
#!/usr/bin/perl use strict; use warnings; use CGI; use CGI qw(:standard); use JSON; use Data::Dumper; my $q = new CGI; print $q->header("application/json"); my $data = decode_json($q->param('dataString')); print Dumper $data;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Read JSON data from a form
by Corion (Patriarch) on Dec 29, 2013 at 18:24 UTC | |
by Anonymous Monk on Dec 29, 2013 at 19:18 UTC | |
by Corion (Patriarch) on Dec 29, 2013 at 19:22 UTC | |
by Anonymous Monk on Dec 29, 2013 at 19:33 UTC | |
by Corion (Patriarch) on Dec 29, 2013 at 19:38 UTC | |
Re: Read JSON data from a form
by tangent (Parson) on Dec 29, 2013 at 20:06 UTC | |
by Anonymous Monk on Dec 29, 2013 at 21:42 UTC | |
by tangent (Parson) on Dec 29, 2013 at 21:54 UTC | |
by Anonymous Monk on Dec 30, 2013 at 01:13 UTC | |
by Anonymous Monk on Jan 07, 2015 at 09:05 UTC | |
by Anonymous Monk on Jan 07, 2015 at 08:55 UTC |