I'm trying to AJAX post my form to two different systems using the code below:
if (loyaltyForm == true) {
console.log(result);
jQuery.ajax({
type: "POST",
url: 'https://example.execute-api.eu-west-1.amazonaws.com/Deployment',
contentType: 'application/json',
data: JSON.stringify(result),
success: function(res) {
redEyeForm.replaceWith("<div class='successmessage'>Success Message to go here</div>");
},
error: function() {
redEyeForm.replaceWith("<div class='successmessage'>Error Message to go here</div>");
}
});
var $form = $(this);
var form = document.getElementById("signup");
jQuery.ajax({
type: "POST",
url: $form.attr('action'),
contentType: $form.serializeArray(),
});
}
Only the 2nd ajax works, why would that be?