Use ajax to display the message on sending email from forms.
<div id="form-result"></div>
<script>
$(document).ready(function(){
var form = $('#contact-home');
form.submit(function(e) {
// prevent form submission
e.preventDefault();
// submit the form via Ajax
$.ajax({
url: form.attr('action'),
type: form.attr('method'),
dataType: 'html',
data: form.serialize(),
success: function(result) {
// Inject the result in the HTML
$('#form-result').html(result);
$('#button').text("Sent!");
}
});
});
});
</script>
"#form-result" is displayed, everything is fine.
But the button text in form is not changed after sending. Tell me how please.