Hello,
I am trying to post data to MySQL without having the webpage refreshing (the URL will not change when sending data to MySQL). I think I can do this using jQuery or AJAX. I believe this is the proper way to do this but it does not seem to work. I can get data inserted into MySQL if I use an action="insert_db.php" as part of the form but that will redirect to that webpage, that is, it goes to insert_db.php. I do not want it to redirect to any other webpage when it is inserting data into the database. Does anyone know how this is possible to do? Thank you very much for any help.
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function() {
$("submitbutton").click(function() {
$.ajax("insert_db.php");
});
});
</script>
</head>
<body>
<form id="myForm" name="form" method="post" action="">
<input type="text" name="num1" id="var1" value="" maxlength=2 size=1 class="textbox">
<input type="text" name="num2" id="var1" value="" maxlength=2 size=1 class="textbox">
<input type="text" name="num3" id="var1" value="" maxlength=2 size=1 class="textbox">
<input type="text" name="num4" id="var1" value="" maxlength=2 size=1 class="textbox">
<input type="text" name="num5" id="var1" value="" maxlength=2 size=1 class="textbox">
<input id="submitbutton" type="submit" name="senddata" value="Submit Data" method="post">
</form>
</body>
</html>