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...


In reply to perl cgi server response issue or not? by heatblazer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.