我的一个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';
}