javascript - 无法在 django/ChatterBot 示例中使用 jQuery 的 .html(text) 方法加载图像
问题描述
ChatterBot 训练数据集
image_data.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
在 chrome 控制台中给出错误。
解决方案
推荐阅读
- python - 如何在 Selenium python 中复制元素文本
- python - Python中的幂律分布拟合
- php - 用户在 Laravel 6.18 中使用条件登录后检查用户的每个请求
- c++ - 在 C++ 中将比较运算符作为参数传递的最佳方式(性能方面)
- image-processing - 围绕自定义焦点裁剪和调整图像大小
- javascript - 通过内部文本选择一个 h2
- python - 在python中的集合和元组之间来回切换
- sql - ';' 附近的语法不正确。期待对话
- javascript - 停止在 dygraphs 中自动更改 y 轴范围?
- google-sheets - 使用索引功能在 Google 表格中导入范围以获取最新预算