in reply to Re^2: perl cgi server response issue or not?
in thread perl cgi server response issue or not?
When you call the open() and send() methods on your URL, that does the request, but you never do anything with the data your server returns. Look into the properties responseText and responseXML to get at your data. You'll also need to use the onreadystatechange event to know when the data is ready for use.
Or you could replace the entire Javascript portion with a few lines of jQuery. It takes a lot less typing to get and change the values of elements, and the ajax routines (here using get) provide callbacks that will be fired when the data is ready (or under other conditions you may want to catch). You also don't have to construct a query string for your URL, and worry about what happens if people put unexpected characters in the fields.
$(document).ready(function() { $("#submit").click(function(e) { e.preventDefault(); // don't let browser submit var name = $('#name').val(); var age = $('#age' ).val(); if( name && age ){ $.get(url, { name: name, age: age }, function(data){ $('#somediv').html(data); // replace div contents with new + data }); } else { alert('Missing form fields!); } }); });
Aaron B.
Available for small or large Perl jobs; see my home node.
|
---|