How to insert data into mysql database without page refresh using jquery ajax and php. Here in this video I will save data into database using mysqli insert query and jquery ajax with php. I have created a simple html form just as an example to explain how to insert data without page refresh with the help of jquery ajax and php. jquery ajax insert data mysql php.
I have created a simple html form with save button. In jquery script I have created a button click function within this function I have called ajax functionality.
In ajax first step is url which is the insert_data.php file. This file we will create for backend php coding. Second step in ajax is the type of the html form which is post.Third is the data, In data I have passed a variable data which is the id of form with jquery serialize function plus button id. We can pass one by one id of each input field which is second method of performing ajax.But I have passed form id in data.
Last step is the success function of ajax which will call after performing ajax functionality and give us a response message either our data saved into database or failed to save data.