Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: perl cgi server response issue or not?

by heatblazer (Scribe)
on Jun 10, 2012 at 11:39 UTC ( #975415=note: print w/ replies, xml ) Need Help??


in reply to Re: perl cgi server response issue or not?
in thread perl cgi server response issue or not?

Well, good point but no, everything seems to be OK, the only problem is that perl`s script output does not display into the browser. That is strange since I`ve tested direct form validation without JS and it is working ok... But here it`s fishy...


Comment on Re^2: perl cgi server response issue or not?
Re^3: perl cgi server response issue or not?
by Anonymous Monk on Jun 10, 2012 at 12:24 UTC

    Well, good point but no, everything seems to be OK, the only problem is that perl`s script output does not display into the browser. That is strange since I`ve tested direct form validation without JS and it is working ok... But here it`s fishy...

    Maybe you should figure out why? something something http headers

Re^3: perl cgi server response issue or not?
by aaron_baugher (Deacon) on Jun 11, 2012 at 01:49 UTC

    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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://975415]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2014-09-23 01:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (210 votes), past polls