tags:

views:

239

answers:

3

I have this form:

<form name="input" action="http://s164074194.onlinehome.us/mail.py" method="POST">
Username:
<input type="text" name="email" />
<input type="submit" value="Submit" />
</form>

On submission, the mail.py script is called and the user is redirected to its output...

I'd like the user to just stay on the same page as the form, right now when I click submit on the form I'm redirected to mail.py, which is on another site. Is it possible to disable this redirect action and instead just invoke the script?

Thanks

+1  A: 

Submit it via AJAX.

josh
If the script that the form is submitted to is on a different site, AJAX won't work due to the same-origin policy.
pkaeding
+1  A: 

As @josh mentioned, you probably want to submit the form via AJAX, but if the script is on another site, then I don't think you will be able to do that.

Probably your best bet is to have a hidden iframe with the real form that gets submitted, and when the user clicks the button on the visible form, some javascript copies the field values to the hidden form, and submits it.

You might also be able to just specify a target on the form to be the hidden iframe, and not worry about the javascript part, but I haven't tried it.

pkaeding
A: 

One solution would be to have mail.py redirect the browser to a different page once it has finished running whatever functions with the form data.

I'm not sure of the situation you have but if you don't have access to edit mail.py then perhaps you can get a local copy of it if possible.

T Pops