【发布时间】:2022-01-02 02:29:44
【问题描述】:
我正在使用 Django,在我看来,我正在向我的页面发送 HTML 字符串:
<p><code>202</code> </p><p>hello world/p>
<ul>
<li>Goodbye<strong><em>next</em></strong> or <strong><em>happy</em></strong> to go on.</li>
</ul> byebye <p><3</p>
但是,它被发送到页面:
var html_smallest_steps =
<p><code>202</code> </p><p>hello world/p>
<ul>
<li>Goodbye<strong><em>next</em></strong> or <strong><em>happy</em></strong> to go on.</li>
<
我的页面上出现控制台错误:
Uncaught SyntaxError: Unexpected token '&'
我的views.py是:
def displayDict(request):
html_ss =
"""
<p><code>202</code> </p><p>hello world/p>
<ul> <li>Goodbye<strong><em>next</em></strong> or <strong><em>happy</em></strong> to go on.
</li> </ul> byebye <p><3</p>
"""
return render(request, 'chatStream.html',
{"html_sss": html_ss})
chatStream.html 是:
<p id="chatLine">get this working!!</p>
<script>
var html_smallest_steps = {{html_smallest_steps}}
}
setTimeout(myTimeout2, 2000)
function myTimeout2() {
document.getElementById("chatLine").innerHTML = "html_ss " + html_ss;
}
</script>
【问题讨论】:
标签: javascript python html django