我们可以在jsp页面中用java初始化JavaScript变量吗?喜欢,
<script type="text/javascript">
var refreshId = setInterval(function() {
var nv=<% out.print(num_voted); %>;
var tv=<%out.print(totalvoted); %>;
var m=<% out.print(month);%>;
var y=<% out.print(year);%>;
alert("refreshed");
$('#alertmessagebox').text("Total members voted "+nv+" out of "+tv+" for "+m+" " +y);
}, 9000);
$.ajaxSetup({ cache: false });
</script>
代码未按预期工作。:(
有没有办法做到这一点?为什么不可能通过这种方式?我们需要创建标题来做到这一点吗?