no page refresh and no getting to submitpage with jquery.form.js ???
All I need is a MySQL update by pressing the submit button. The user sould't get on the php site by pressing the Submitbutton and when it's possible there should't be a page refresh by pressing the submit button.
The jquery.form.js plugin also didn't work that way.
my js:
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de-de" lang="de-de" >
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="jquery.form.js"></script>
<script type="text/javascript" >
$(document).ready(function(){
$('#myForm2').submit(function() {
// inside event callbacks 'this' is the DOM element so we first
// wrap it in a jQuery object and then invoke ajaxSubmit
$(this).ajaxSubmit(options);
alert("test");
// !!! Important !!!
// always return false to prevent standard browser submit and page navigation
return false; ....
my html:
- <form id="myForm2" action="ubergabe.php" method="post">
Name: <input type="text" name="name" />
Comment: <textarea name="comment"></textarea>
<input type="submit" value="Submit Comment" />
</form>
my php (ubergabe.php):
- <?php
$link = mysql_connect('localhost', 'vogelsql2', '*****');
if (!$link) {
die('keine Verbindung möglich: ' . mysql_error());
}
mysql_select_db("vogelsql2");
mysql_query("UPDATE test SET price = '333'
WHERE id = '2'");
?>
When I'm pressing the submit button it brings me to ubergabe.php it must be possible that i'm staying on the mainpage.