Staying in the same page without refreshing it after adding to database

后端 未结 2 1036
挽巷
挽巷 2021-01-27 12:59

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

2条回答
  •  时光取名叫无心
    2021-01-27 13:24

    In your HTML file you have action = 'insert.php' in

    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 , page gets refreshed so go for ajax. Keep the script for click event.

    1. Remove action="insert.php" and method="post" from tag.
    2. Change type = "button" in

    Hope this will help.

提交回复
热议问题