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