Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-20 04:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found