I am trying to change button text on button click before sending an AJAX request. The text is not changing until after the AJAX success has run. Why is this happening?
I also tried using the trigger and change functions.
$(function() {
$("#contactbutton").click(function(e) {
var $this = $(this);
$this.text('Submitting....');
$('#contactbutton').prop('disabled', true);
e.preventDefault();
var name = $("#name").val();
var dataString = 'name=' + name;
$.ajax({
type: "POST",
url: "emailsend.php",
data: dataString,
success: function() {
window.open("thankyou.php");
},
async: false
});
return false;
});
});