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.


In reply to Re^3: perl cgi server response issue or not? by aaron_baugher
in thread 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.