2017-10-05 39 views
0

我試圖通過組件回jQuery.ajax調用,然後設置HTML。散景組件渲染通過jquery.success

背景虛化代碼:

layout = column(plot) 
script, div = components(layout) 
res_json = jsonify(dict(script=script, div=div)) 
return res_json, 200, {'Content-Type': 'application/json'} 

jQuery的

success: function(data) { 
    $("#bokeh_script").html(data["script"]); 
    $("#bokeh_div").html(data["div"]); 
} 

然而,我得到這個錯誤: enter image description here

我已經做了一些閱讀和它看起來像它可能是一個問題所有事物的加載順序。我也很好奇,如果你甚至可以傳遞一個像.html(<script>)這樣的標籤並且它仍然載入?謝謝。

回答

0

隨着背景虛化的呈現順序確實重要,因此AJAX調用必須呈現腳本之前股利:

success(function(data){ 
    $("#bokeh_div").html(data["div"]); 
    $("head").append(data["script"]); 
});