json.success重定向到感谢页面


json.success redirect to thank you page

我的一个PHP模板中有这段代码。

// IF successful hide the form and show thanks
if (json.success) {
    $('#payment-form').hide();
    $('#thank-you').show();
}

如果我想重定向到thank-you.php而不是显示#thank-you,这段代码可能吗?或者我必须做其他事情吗?

您可以通过更改location.href属性来重定向到新页面:

if (json.success) {
    location.href = '/thank-you.php';
}

使用此

if (json.success) {
   window.location.href = 'thank-you.php';
}