weixin_33704234 2020-03-10 10:19 采纳率: 0%
浏览 62

两篇AJAX帖子-仅一篇作品

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?

  • 写回答

0条回答 默认 最新

    报告相同问题?