template in Flask on JS click event
This question already has an answer here:
$.get
just sends an HTTP request to your server, but doesn't actually do anything anything with the data (in your case, the rendered template) it gets back from the server.
Try something like this:
$("#load_btn").click(function() {
$("html").load("/callback");
}
Or if the template you render doesn't contain any <head>
tags, only body content, you can do
$("#load_btn").click(function() {
$("body").load("/callback");
}
Or, you can exchange "body" for a specific element to only replace a specific part of the page.
If you want the user to be redirected, do this:
$("#load_btn").click(function() {
window.location = "/callback";
}
链接地址: http://www.djcxy.com/p/12464.html
下一篇: JS烧瓶上的模板点击事件