【发布时间】:2016-11-03 09:52:13
【问题描述】:
我正在尝试在我的 Thymeleaf 页面中进行 Ajax 调用。所以这里是代码
<script>
function getTodayRequest(){
console.log("here is today");
var xhttp=new XMLHttpRequest();
xhttp.onreadystatechange=function(){
if(this.readyState==4 && this.status==200){
document.getElementById("received").innerHTML=
this.responseText;
}
};
xhttp.open("GET","URI",true);
}
</script>
所以它符合错误:
the entity name must immediately follow the '&' in the entity reference. java
我已将&amp; 更改为&amp;,现在看起来像:
if(this.readyState==4 && this.status==200)
但现在它再次抱怨:
Uncaught SyntaxError: Unexpected token ;
在第二个&amp;
我该如何处理?
【问题讨论】:
-
我不是专家,但是您可以将脚本代码包装在 html 注释中,即
<script><!-- code //--></script>。 -
很遗憾,
&amp;在 JS 中不是一个有效的运算符。那是一个 HTML 实体。 -
您使用的是什么文档类型?在 HTML5 中需要使用 cdata...stackoverflow.com/questions/66837/…
标签: javascript html thymeleaf