I just watch this video and others video. All of them use ajax with 2 .php files but i already have file content.html that contain forms and content.php that submit form to database. how can i use ajax with my html file to submit form without reloading page. https://www.youtube.com/watch?v=IOONJgPclwU
Asked
Active
Viewed 1,433 times
2 Answers
0
Utilizing the jQuery library you can use code like
$("#theForm").ajaxSubmit({url: 'server.php', type: 'post'})
Please reference jQuery AJAX submit form as it answers your question very well.

Community
- 1
- 1

Jesse Hockenbury
- 114
- 5
0
This is not a new question but still you can take help from this code
$(document).ready(function(){
$("button").click(function(){
$.ajax({url: "submit_form.php", success: function(result){
$("#div1").html(result);
}});
});
});

Shubhranshu
- 511
- 3
- 12
-
I already try this code but it doesn't work. It still reloading new page – Splicee Jan 24 '17 at 06:15
-
-
Add `.click(function(e)` (added the `e`) and the add this in the first row in the `click`-callback: `e.preventDefault();` – M. Eriksson Jan 24 '17 at 06:26