$.post('contact.send.php', { key1:value1, key2:value2, ... , keyn:valuen }, function(txt) {} );
You can also look at the form plugin which provides a way to automatically include form inputs.
Blair
On 10/17/06, Arne-Kolja Bachstein <
[EMAIL PROTECTED]> wrote:
Klaus Hartl schrieb:
> Welcome Arne!
>
> I think you have to move the "return false" out of the callback function
> to switch off the forms default action. The way it is now both form
> submission and $.post would interfere.
>
>
> $('#contactForm').submit(function(){
> $.post('contact.send.php','',function(txt) {
>
> $("#kontaktformular").before("<div
> class=\"returnMessage\">"+txt+"</div>");
>
> });
> return false;
> });
>
> Another hint: removing the element from your selector should result in
> better performance, because jQuery doesn't have to look for all elements
> of a type before checking for the id:
>
> $('#contactForm')
>
> -- Klaus
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
Hi Klaus,
thank you for your helpful answer. It helped me at least with about the
fact that the script is now executing the script at every single call
and it now doesn't reload the html page automatically any more. So I am
a great step further now. But there's some other problem now. It seems
like the function now calls the script, but doesn't transmit(!) the post
request. My contact form checks in an if-statement if the variable
$_POST['message'] is set and always jumps to the else handler, so it is
_not_ set. I tried to echo all the given $_POST and $_REQUEST variables
in a while/each statement, but this doesn't output anything (an echo
"test<br />" on the other hand works flawlessly). So I assume there is
simply nothing transmitted. How can this be? :-/
My form is a simple and correctly formatted form without method and
action attributes (which should work when sending it via Ajax), I am, of
course, sending via .post() and not .get() and the input fields are
named correctly (no id, just name attribute). So any ideas? :-/
Here's a copy and paste of the Ajax part again, just to make sure it's
correctly adopted:
$('#contactForm').submit(function(){
$.post('contact.send.php','',function(txt) {
$("table#kontaktformular").before("<div
class=\"returnMessage\">"+txt+"</div>");
});
return false;
});
Best regards,
Arne
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
_______________________________________________ jQuery mailing list [email protected] http://jquery.com/discuss/
