无法使用Flask和jquery/json更新值

无法使用Flask和jquery/json更新值,jquery,python,flask,Jquery,Python,Flask,各位同事: 我正在设计一个网页,以显示一个衡量,需要更新每一秒。我正在使用flask和jquery。我不知道为什么,但没有更新页面上的值(entu direc) 我有: @app.route('/update',methods=['GET']) def retorno(): get_value() return jsonify(ent_direc=ent_direc) 在我的index.html页面上 <!DOCTYPE html> <html> <

各位同事:

我正在设计一个网页,以显示一个衡量,需要更新每一秒。我正在使用flask和jquery。我不知道为什么,但没有更新页面上的值(entu direc)

我有:

@app.route('/update',methods=['GET'])
def retorno():
    get_value()
    return jsonify(ent_direc=ent_direc)
在我的index.html页面上

<!DOCTYPE html>
<html>
<body>

<canvas id="canvas" width="400" height="400" style="background-color:#ffffff"></canvas>
<script>
 var canvas = document.getElementById("canvas");
 var ctx = canvas.getContext("2d");
 var radius = canvas.height / 2;
 var ent_direc={{ent_direc}};
 ctx.translate(radius, radius);

 drawClock();

 setInterval(function(){update_values()}, 1000);

function drawClock()
{
    drawFace();
    drawNumbers();
    drawTime();
    drawMajorticks();
    drawMinorticks();
}

function update_values()
{

         $SCRIPT_ROOT = {{ request.script_root|tojson|safe }};
            $.getJSON($SCRIPT_ROOT+"/update",ent_direc,
                function(data) {
                    drawClock();

                });
}

var canvas=document.getElementById(“canvas”);
var ctx=canvas.getContext(“2d”);
变量半径=画布高度/2;
var ent_direc={{ent_direc};
平移(半径,半径);
挂钟();
setInterval(函数(){update_values()},1000);
函数drawClock()
{
drawFace();
数字();
提取时间();
drawMajorticks();
drawMinorticks();
}
函数更新_值()
{
$SCRIPT_ROOT={{request.SCRIPT_ROOT|tojson|safe};
$.getJSON($SCRIPT\u ROOT+“/update”,ent\u direc,
功能(数据){
挂钟();
});
}
我的问题是,当我执行update_values并接收到ent_direc的更新值时,是否可以直接调用全局函数drawClock()?我的意思是,我在代码的中间跳动,用的是CTX或画布。 你知道哪里不对吗?当然,问题出在客户端,因为如果我转到/update,我会在页面上显示我的变量

顺便说一句,还可以看到get消息,因此客户端请求变量,它从服务器获取变量,但不更新我的页面

192.168.1.7---[12/Sep/2015 01:10:51]“获取/更新HTTP/1.1”200-
192.168.1.7---[12/Sep/2015 01:10:52]“GET/update HTTP/1.1”200-

缺少大量代码,因此很难准确地看到问题的发展方向。您能用创建一个JSFIDLE吗?有相当多的代码丢失,很难准确地看到问题的发展方向。您可以创建一个带有?