In my index.php, I have an update button as below.
<form action="update.php" method="post" >
<button type="submit">Update</button>
</form>
I have defined a javascript function to override the default form action. The javascript function is as below.
<script type="text/javascript">
$(document).ready(function() {
$('form').submit(function(e) {
e.preventDefault();
alert("HI");
$.ajax({
type: 'post',
url: 'update.php',
data: {
source1: "some text",
},
success: function( data ) {
console.log( data );
}
});
});
});
</script>
After I click on the update button, I am getting the alert. However, I am not redirected to update.php page as expected. I am trying to send some values in the ajax request which can be used for processing in the update.php page.
update.php? How is this question any different to any of the Related questions over there? --->