I have a form on my page, and some javascript which uses ajax to submit the form, and then opens the new page in a div using ajax so there is no refresh. This works fine. But the problem is this: all values seem to pass except what the submit buttons say. I have a preview button and a finish button, and need to check which was pressed. I can add a checkbox for submit, but that's annoying.
I'm using mootools for the ajax call, so it might not look like regular ajax, but...
This basically is posting the form (frmName) to the div (el).
So question is, since I'm using return false to stop the form from submitting, does it not send the submit buttons values in post?
In case it helps, the form...
[html]<form action="content/blog/submit.php" id="addBlogForm " method="post" onSubmit="retur n submitForm(\'ad dBlogForm\', \'previewBlogDi v\');">
... form stuff here...
<input type="submit" class="submit" name="preview" value="Preview" />
</form>[/html]
And then my php script (submit.php) ...
[php]if($_POST['preview']) {
include('replac e.php');
} else {
...
[/php]
It always runs the else statement though, apparently not catching the $_POST of preview?
I'm just trying to figure out what I did wrong in this, since that's about all that I can't check in my php script when it's submitted.
I'm using mootools for the ajax call, so it might not look like regular ajax, but...
Code:
submitForm = function(frmName, el) {
$(frmName).send({update: $(el), onComplete: function() {MOOdalBox.init()}});
return false;
}
So question is, since I'm using return false to stop the form from submitting, does it not send the submit buttons values in post?
In case it helps, the form...
[html]<form action="content/blog/submit.php" id="addBlogForm " method="post" onSubmit="retur n submitForm(\'ad dBlogForm\', \'previewBlogDi v\');">
... form stuff here...
<input type="submit" class="submit" name="preview" value="Preview" />
</form>[/html]
And then my php script (submit.php) ...
[php]if($_POST['preview']) {
include('replac e.php');
} else {
...
[/php]
It always runs the else statement though, apparently not catching the $_POST of preview?
I'm just trying to figure out what I did wrong in this, since that's about all that I can't check in my php script when it's submitted.
Comment