javascript - Uncaught SyntaxError: Invalid or unexpected token when using $(element).html to include jsp
问题描述
我是 JAVA 的新手(JSP 和 JSTL)
我对 api 端点进行 Ajax 调用,在回调中我想加载一个 jsp 文件,其中包含 jsp。所以,我做类似的事情
AjaxQueueManager.get("/xyz/abc/" + efg,
function(data) {
if (data.success) {
$(element).html('<jsp:include page="includes/jsp-file.jsp" />');
} else {
getResourcesFailureCallback(element, data.errors, "ocon-wrong", "Something's Wrong!");
}
},
function(error) {
console.log("#####", error.status, error.statusText);
}
);
如果我的 jsp-file.jsp 不包含任何 javascript 一切正常,例如,如果我把
<p>Hello World</p>
它工作正常,但是一旦我将 javascript 放入 jsp 文件中,即使是最基本的 javascript
console.log("hello world");
我收到一个错误
Uncaught SyntaxError: Invalid or unexpected token
$(element).html("<script type="text/javascript">
我理解这个错误,它的原因是“混入了”,type="text/javascript"
但我不知道如何解决它。
解决方案
推荐阅读
- java - BabelNet 中的域限制
- python - 如何在 Toplevel 上存储数据?
- javascript - 用户滚动后更改标题背景
- scala - word2vec-余弦相似度的评估
- swift - 有没有办法在包含通配符的数组上使用 switch 快速?
- google-sheets - 在 google 工作表中添加 2 条细线以创建新的迷你图
- html - 无法在页面上将 SVG 波形移得更高(HTML / CSS)
- django - 带有 Django 管理员的 REST API
- python - 我们如何在 PyModbus 库中生成流量?
- sql - 如果 MV 使用 ASNI Join,查询重写失败