views:

27

answers:

3

Does anybody know of a simple JQuery form processing tutorial that actually works?

I have a form I want to process via JQuery/Ajax nothing difficult in PHP but in JQ and AJAX can I get it to work - no, all the tutorials are based round sending e-mails (or just lists of more lists of more lists of tutorials - hate those)

All I want to do is learn how to send a form via JQ and AJAX to another page, save the data in a DB without having to leave the first page. I have tried all sorts but nothing works propery. Here is my form:

<form id="form">
<input type="text" name="abc" />
<input type="text" name="def"/>
<input type="text" name="ghi"/>
<input type="submit" name="try" id="try" />
</form>

Now what do I actually do? Sounds silly I know (and I guess I'll get another -1 star for this question) but I will be honest a GOOD simple tutorial would be really useful not just to me but to the others. I know php but JQuery/Ajax - just don't know/understand. I wil not be alone

A: 

This is one of the good tutorials on how to submit forms using ajax and php.

Sarfraz
A: 

This link is a reference teaching how to submit forms via jQuery/AJAX. Have the form post to a PHP page to handle the form data.

In short, your jQuery code would look similar to this:

$("#form").submit( function()
{
    // Handle validation or any extra data here.
    // Return true if validation passed and the data should be posted
    // Return false if the form should not be submitted

    // You can also do any extra work here that you like before returning,
    // including changing something on the page or showing the user a message.
}
Aaron
+1  A: 

There's a cracking plugin for this:

http://plugins.jquery.com/project/form/

It's as easy as:

$('#myForm').ajaxForm(function() { 
    alert("Thank you for your comment!"); 
}); 
Sohnee