简体   繁体   中英

Load new page on a button click (the button intentionally has no form)

There is a button on a page:

<input type="button"
         onclick="clickProcessOrder()"
         id="order-button"
         value="Order">

The function it triggers looks like this:

function clickProcessOrder() {
    $.get("/checkout");
}

The /checkout endpoint looks like this:

@app.route('/checkout', methods=['GET'])
def checkout():
    return render_template('checkout.html')

When I click a button, I can see that the get request successfully comes through:

127.0.0.1 - - [09/Aug/2019 17:17:05] "GET /checkout HTTP/1.1" 200 -

But I do not get redirected to checkout.html page. I stay on the same page.

What am I doing wrong? Is it possible to get redirected to checkout.html page through /checkout endpoint?

在您的职能中,您可以

window.location.href = "checkout.html";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM