heatblazer has asked for the wisdom of the Perl Monks concerning the following question:
Hello all
I am trying some really basic server script for outputing a html page. Firefox firebug says it`s OK but I don`t see a thing. Can you look at my code?
here is my html form:
<!DOCTYPE html> <html> <head><title>PERL TEST</title> <script> window.onload = function() { var pressIt = document.getElementById('submit'); pressIt.onclick = populatePage; }; function populatePage() { var req = newRequest(); var url = "http://localhost/cgi-bin/response.pl"; var name = document.getElementById("name").value; var age = document.getElementById('age').value; console.log(name, age); if ( name && age && req ) { url += ("?name=" + name + "&age="+age); req.open("GET", url ); req.send(url); } } function newRequest() { try { var request = new XMLHttpRequest(); } catch ( otherMS ) { try { request = new ActiveXObject("Msxml2.XMLHTTP"); } catch ( otherMS ) { try { request = new ActiveXObject("Microsoft.XML +HTTP"); } catch ( failed ) { request = null; } } } return request; } </script> </head> <body bgcolor="#ccffcc"> <h1>Please fill the small form below</h1> <form> <input type='text' value='' id='name' name='name' >Enter name</inp +ut> <input type='text' value='' id='age' name='age' >Enter age</input> <input type='button' value='Submit' id='submit' > </form> </body> </html>
And Perl`s response form cgi-bin:
#!/opl/lampp/bin/perl use strict; use CGI; ## RESPONSE TO XMLHTTP: my $response = CGI->new(); my ( $name, $age ) = ($response->param("name"), $response->param("age" +) ); if ( $name && $age ) { print "Content-type: text/html\n\n"; print "<html><head></head>"; print "<body><h1>Hello $name </h1></body>"; print "</html>"; } else { exit(0); }
Don`t mind the example, I see in the debug that server responded OK, but I don`t see the actual HTML page...
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: perl cgi server response issue or not?
by aaron_baugher (Curate) on Jun 09, 2012 at 16:52 UTC | |
by heatblazer (Scribe) on Jun 09, 2012 at 20:01 UTC | |
by aaron_baugher (Curate) on Jun 09, 2012 at 21:08 UTC | |
Re: perl cgi server response issue or not?
by Anonymous Monk on Jun 10, 2012 at 07:31 UTC | |
by heatblazer (Scribe) on Jun 10, 2012 at 11:39 UTC | |
by Anonymous Monk on Jun 10, 2012 at 12:24 UTC | |
by aaron_baugher (Curate) on Jun 11, 2012 at 01:49 UTC |