代码之家  ›  专栏  ›  技术社区  ›  shaik moeed

在django/ChatterBot示例中使用jQuery的.html(文本)方法无法加载图像

  •  0
  • shaik moeed  · 技术社区  · 7 年前

    ChatterBot训练数据集

    图像数据.yml:

    categories:
    - myown
    conversations:
    - - show me famous book image?
      - <img src="{% static 'img/Book.png' %}"  height="50" width="50"> //this line is sent as **text** in $row.html(text); 
    

    jQuery代码:

      function createRow(text) {
        var $row = $('<li class="list-group-item"></li>');
    
        $row.empty().html(text); //$row.html(text); #Both are not working
        $chatlog.append($row);
      }
    

    应用程序.html:

    {% load staticfiles %} //on top of file
    ...
    ..
    ...    
    <ul class="list-group chat-log js-chat-log">
        //here <li class="list-group-item"></li> element will appended.
                                </ul>
    

    GET http://127.0.0.1:8000/%7B%%20static%20'img/Book.png'%20%%7D 404 (Not Found)
    

    问题是,它没有考虑 {% load staticfiles %} . 这就是为什么它不渲染我的图像。有人能帮我吗?

    如果我提供在线图像链接作为来源,它是工作的。 但是,当我试图给出完整的局部路径时,它给出了 not allowed to load local resource

    0 回复  |  直到 7 年前