in reply to Re^4: submit data without reload
in thread submit data without reload
other thing. i have been trying to get param from html. but its not working
TEST.PL #!/usr/bin/perl -w print "Content-type: text/html\n\n"; print <<END_HTML; <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" /> <title>Untitled Document</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery +.min.js"></script> <script> \$(document).ready(function () { \$("#Submit").click(function(event) { Execute(); }); function Execute(){ \$.ajax({ type: 'POST', url: 'te.pl', data: { 's': '' }, success: function(res) { \$('#result').text(res.msg); }, error: function() { alert("failed"); } }); }; }); </script> </head> <body> <form method="post"> Fullname: <input type="text" name="fname"><br> <p id="result" >Name Is:</p> <input type="button" id="Submit" name="Submit" value="Submit"/> </form> </body> </html> END_HTML
TE.PL #!/usr/bin/perl -w use JSON; use CGI; my $q = new CGI; my $name = $q->param("fname"); my $json = encode_json( { msg => $name } ); print $q->header( -type => 'application/json' ),$json;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: submit data without reload
by poj (Abbot) on Jan 23, 2019 at 21:25 UTC | |
by bigup401 (Pilgrim) on Jan 24, 2019 at 09:24 UTC |