Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: retrieving value from ajax call to cgi page

by gayu_justin (Novice)
on Jun 29, 2013 at 12:04 UTC ( [id://1041456]=note: print w/replies, xml ) Need Help??


in reply to Re: retrieving value from ajax call to cgi page
in thread retrieving value from ajax call to cgi page

On checking, i found that the page process.cgi is getting the value and since, this is an jax call, the value will not get print in the browser. please help me to take the value and all the text box value will be in the single variable

  • Comment on Re^2: retrieving value from ajax call to cgi page

Replies are listed 'Best First'.
Re^3: retrieving value from ajax call to cgi page
by derby (Abbot) on Jun 29, 2013 at 12:37 UTC

    Help me understand 'will not print in the browser.' Your JQuery snippet above just alerts the data, are you seeing the value in the alert box or not?

    If not, when you click on the network tab in firebug, look for your URL and ensure the response code was 200 (or whatever success code you're sending). If the ajax call http response was not successful, check your server error logs for any server side issues.

    If the ajax call was successful, click on the URL in firebug and click on the response tab. Is the data coming back the way you expect? If not, then check your server side logic to ensure you're doing what needs to be done (you can post your perl snippets then).

    If the data is coming back correctly, then double check the console tab in firebug -- you may have some other javascript error that's causing problems.

    -derby

    update: forgot to add, there's nothing special about AJAX for the perl/server side perspective. Wether the call is AJAX or the result of a click on an anchor element, perl/server side could care less. Many times when I'm debugging JQuery, I do the testing outside of the page on which the AJAX call resides. Wether that's a simple http://foo.com/cgi-bin/process.cgi?value=bar call on the browser or something more complicated via POSTing, it doesn't matter.

Re^3: retrieving value from ajax call to cgi page
by poj (Abbot) on Jun 29, 2013 at 13:25 UTC
    try data : { value1: 'value1' },

    Here is my working test, an html page

    <html> <head> <script src="jquery-2.0.2.min.js"></script> <title>test-ajax.htm</title> <script> $.ajax({ url: 'process.cgi', // The type of request. type: "get", data : { value1: 'value1' }, success: function( data ){ alert(data); $( "#value1" ).html( "<strong>" + data + "</strong>" ); } }); </script> </head> <body> <span style="background-color:yellow" id="value1">?</span> </body> </html>
    and a process.cgi script.
    #!perl # process.cgi use strict; use CGI; my $q = CGI->new; print $q->header; print $q->start_html, 'Data returned is '.$q->param('value1'), $q->end_html;
    poj

      Okay, now from your browser-debugger add the actual GET/POST text, headers and all, that is being sent by your browser.   Also, notice how in the CGI example param() is being assigned to an @array ...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-18 18:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found