tags:

views:

39

answers:

1

I am really trying to get somewhere with JQuery, but I just cannot getit to process forms. Here is my (test) code :

<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>

and the jquery

$(document).ready(function($) {
$("#try").click(function() {

$.post("process.php", $("#form").serialize());    
});
});

As a simple test I am have this on process.php and if I access process php direct it works

mysql_query("INSERT INTO testit (tryit) VALUES ('1')"); 

if I then try

$tryit = $_POST['abc'];
mysql_query("INSERT INTO testit (tryit) VALUES ($tryit)");

i.e accessing the post variable abc nothing happens

Yes I do connect to the DB

Why does the JQuery not go to the page process.php?

The serialization works as I can see this in the browser

testit.php?abc=q345&def=345&ghi=2345&try=Submit+Query

What I really want to do is POST the form variables into the DB table, why can I not get it to work? either as above or by trying to post the variables?

A: 

Try

$(document).ready(function() {
    $("#form").submit(function(){
        $.post("process.php", $("#form").serialize());    
    });
});
rahul