Hi

The main difference between get & post in this case isn't the protocol.
When the browser generates the request object, all the domObject's in the document. object are treated a little differently.

For a GET request, IE will just take what ever is in the current document object and submit it.
For POST it tries to reconstruct the document objects, so something that's dynamically created can often get left out. One of the things to do is see if you can retrieve the contents in an alert prior to the document.form.submit

var fld = document.getElementById("thingThatDoesntWork");
alert(fld.value);

or something similar, may need to google that value thing.
That would be your first step-

If that seems ok, next thing to do is verify that it's not getting lost in the document.submit process
Try the following code which should emulate a web connection (i think, i may have broken it in the past)
Point your form at where ever this is listening, and the port lister below, run it and see what happens.

#!/usr/bin/perl
use IO::Socket;

my $CRLF = "\015\012";
my $port= 8080;
my $socket = IO::Socket::INET->new( LocalPort     => $port,
                    Listen        => $100,
                    Reuse     =>1) or die "cannot create listen socket: $!\n";

$| =1;
my $request;

while(1){
    next unless my $c = $socket->accept;
    #local $/ = "--";
    while( $request = <$c>){
        print "$request";
    }
    print STDERR "$request";
    print $c <<EOH
HTTP/1.1 200 OK
Server: Apache/1.3.6 (Unix)
Connection: close
Content-type: text/html


Hello there :)
EOH
;
}


P

Nishant Asthana wrote on 12/08/2004, 14:09:

Hi,
I thought I would send my problem on this list and see if someone can help me out.
I am working on Address Book on the Web (webmail.aol.com), and it has a UI where you can select addresses to send mail to.
Its a paged UI in the sense that addresses are grouped into alpha buckets, ABC, DEF etc. So if you click on ABC bucket, you see addresses whose last names begin with A or B or C. User can select addresses on one page and can then go to another bucket and select addresses there, then can go back to previous
page, select/deselect address, or go to other page etc. What we need to do is to save all user's selections till he clicks on send mail button.

ADP page has an HTML form with POST and hidden fields. I use a hidden fld to pass list of selected records to other buckets. I am using the following code in the page for links to alphabets
(main.adp) ns_adp_puts "<ahref=\"\" class="moz-txt-link-rfc2396E" href="">"_javascript_:saveSelectedAndSubmitForm();return false;\">ABC</a>&nbsp\;"
The _javascript_ method saveSelectedAndSubmitForm() iterates over selected checkboxes and adds it to the hidden variable, and finally calls document.submit()

In the adp file, I try to get the value of hidden form field and here is what happens. When I use GET, I am able to see that hidden form fld, however, when I use POST, it seems no form data is submitted to the server.
Here is the sample code

(main.adp)
<%
set theformdata [ns_getform]
set rid ""
if {$theformdata != ""} {
         set rididx [ns_set find $theformdata rid]
         if {$rididx != -1} {
                 set rid [ns_set value $theformdata $rididx]
         }
}
%>
<form>
<input type="hidden" name="rid" value="<%=$rid%>">
</form>

$theformdata is null when POST is used.

Is there a difference between the way data is posted with GET and POST ? I think not, but then how can one explain such behavior. I think I am using the correct JS code. Heres a snapshot.
function saveSelected..() {
    document.forms.theForm.rid.value = prevList; // rid is the hidden form fld. prevList is the value assigned to this fld
    document.forms.theForm.action="";
    document.forms.theForm.submit();
}

--
Software Engineer
America Online Inc
Mountain View,CA


-- AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> with the body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of your email blank.



Reply via email to