gpt4 book ai didi

javascript - POST 到外部 URL (webhook) 但重定向到不同的 URL

转载 作者:行者123 更新时间:2023-11-28 05:26:00 25 4
gpt4 key购买 nike

在我的表单中,我将数据发布到作为 Webhook 的外部 URL。用户提交并将数据传递到 webhook 后,我想将用户重定向到确认页面。

我下面的代码有问题。当用户提交表单时,jQuery 确实会将用户带到确认页面,但表单数据不会触发 webhook(不收集数据)。有人可以帮我解决我哪里出错了吗?

这是我的代码:

HTML

<form action="https://externalurl.com/webhook" method="POST">
<input id="email" name="email">
<input id="firstname" name="firstname">
<input id="lastname" name="lastname">
<button type="submit">Submit</button>
</form>

JQuery

    $('form').submit(function() {
$.ajax({
type: 'POST',
url: $(this).attr('action'),
dataType: 'json',
success: function(json) {
window.location.href = "https://www.mypage.com/confirmation";
}
});
return false;
});

提前致谢

最佳答案

表单中有提交按钮吗?

关于javascript - POST 到外部 URL (webhook) 但重定向到不同的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40166222/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com