[英]Load new page on a button click (the button intentionally has no form)
頁面上有一個按鈕:
<input type="button"
onclick="clickProcessOrder()"
id="order-button"
value="Order">
它觸發的功能如下所示:
function clickProcessOrder() {
$.get("/checkout");
}
/checkout
端點如下所示:
@app.route('/checkout', methods=['GET'])
def checkout():
return render_template('checkout.html')
當我單擊按鈕時,可以看到get請求成功通過:
127.0.0.1 - - [09/Aug/2019 17:17:05] "GET /checkout HTTP/1.1" 200 -
但是我不會重定向到checkout.html
頁面。 我留在同一頁上。
我究竟做錯了什么? 是否可以通過/checkout
端點重定向到checkout.html
頁面?
在您的職能中,您可以
window.location.href = "checkout.html";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.