$("#prospects_form").submit(function(e) {
e.preventDefault(); // <==stop page refresh==>
});
// First add jquery
// <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
$(document).ready(function() {
$("#myForm").on('submit', (function(e) {
e.preventDefault();
$.ajax({
url: $(this).attr('action'),
type: "POST",
data: new FormData(this),
contentType: false,
cache: false,
processData: false,
success: function(response) {
$("#myForm").trigger("reset"); // this line is to reset form input fields
alert('submitted');
},
error: function(e) {
alert('Failed to sumit');
}
});
}));
});
//don't forget to add csrf token