[英]Redirecting to new page after closing AJAX popup window
如何在關閉彈出窗口 window 后重定向到新頁面,代碼如下:
send_ajax_formdata("POST","{{ url('/url') }}", {}, fData, {})
.then((resp) => {
if(resp[0].valid == "true") {
success_alert(resp[0].message);
}else {
warning_alert(resp[0].message);
}
elem.removeClass("disabled");
elem.html(text);
})
.catch((err) => {
danger_alert(err.message);
elem.removeClass("disabled");
elem.html(text);
})
單擊按鈕關閉時,它將關閉彈出窗口 window 並禁用腳本 removeClass。 但是返回到存在彈出 window 頁面的頁面,我想將其重定向到新頁面。 怎么做?
您使用 window 位置重定向到 jquery 中的 url。
window.location.href = '/' + resp.data.redirect_path;
在這里, resp.data.redirect_path 是您的重定向 url 變量,您也可以使用實心 url 到任何頁面,例如:
window.location.href = "http://www.google.com";
您可以使用 location.replace
window.location.replace(resp.href);
// let say the href is "https://stackoverflow.com/"
window.location.replace("https://stackoverflow.com/");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.