in reply to Read JSON data from a form
I don't know your exact requirements but I suspect you don't need to send JSON to your script, you may however need to return JSON. This may help you to see the difference:
Javascript
<script type="text/javascript" > $(function() { $(".submit").click(function() { var formData = $("#reply-form").serialize(); alert(formData); $.ajax({ type: "post", url: "code.pl", cache: false, data: formData, dataType: "json", success: function(data) //onSuccess, { alert(data.calling_params); }, error: function() { alert( "Sorry, there was a problem!" ); } }); return false; }); }); </script>
Perl
use strict; use warnings; use CGI; use JSON; use Data::Dumper; my $q = new CGI; my $in = $q->Vars; my $string = Dumper ($in); my $response = encode_json( { calling_params => "$string" } ); print $q->header("application/json"); print $response;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Read JSON data from a form
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 |