I am really trying to get somewhere with jQuery, but I just cannot get it 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?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…