I have PHP web page where I need to insert some information to my database. When insert is done, it refresh the same page. But I\'ve been told that this process is not practical
Add preventDefault to your javascript function
Function(e){
e.preventDefault()
...
}
In your HTML file you have action = 'insert.php' in <form> tag and you are also calling a function on button click having id insert.
Both are doing the same thing - sending values from HTML page to insert.php. In case <form>, page gets refreshed so go for ajax.
Keep the script for click event.
action="insert.php" and method="post" from <form> tag.type = "button" in <button> tag. Hope this will help.