[Tutor] CGI / HTTP
Kent Johnson
kent37 at tds.net
Wed Sep 13 19:46:14 CEST 2006
Rob wrote:
>
> I created a CGI form mailer script that would keep individual email
> addresses private.
>
> The emailer works fine and I have created similar scripts that work.
> However, I wanted to forward the info from a form without having the
> script return any content. So if there are no errors, the visitor would
> only get a javascript alert thanking them for contacting us, no page
> change is made.
>
> I've tried a couple of things and either get a 500 error or the browser
> tries to download the CGI script. I have a feeling that it has to do
> with HTTP headers. Except for content-type:, I don't know how to
> properly use HTTP headers from within a python CGI script.
>
> Is there a way to submit form data to a CGI script and not have anything
> returned?
This is not really a Python question...when you submit a form in the
normal way, the browser expects the server to respond with a new page
which the browser displays. So I don't think you can submit a form with
a normal POST and keep the same page display.
You need to look at alternate methods to send the data to the server
such as XmlHttpRequest (AJAX). Google "ajax form submit" for lots of
suggestions.
Kent
More information about the Tutor
mailing list