Re: Simultaneous post/get?

From: Date: Sun, 11 Jun 2006 14:21:23 +0000
Subject: Re: Simultaneous post/get?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-237759@lists.php.net to get a copy of this message
tedd wrote:
I am trying to use ajax to accomplish this. The following statement works great and does what I want: <input type="submit" value="Submit" onClick="javascript:sndReq()" > However, when I place the statement within a form, like thus -- <form method="post" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="30000"> <input type="hidden" name="stage" value="1"> <input type="submit" value="Submit" onClick="javascript:sndReq()" > </form> -- the statement appears to no longer work.
The form is being submitted to the current URL which will stop any javascript executing at the time. What you need to do is prevent the form from being submitted, or control when it is submitted. Instead of using the onclick attribute on the button you should be using the onsubmit attribute in the form tag to control this. Fairly good explanation of this here:
    http://www.htmlcodetutorial.com/forms/_FORM_onSubmit.html
-Stut

« previous php.general (#237759) next »