
java 在javascript里面获取到一个List怎么把里面的内容显示在页面里面!求大神帮忙给出代码! 5
2个回答
展开全部
这是JS代码
function init(a){
$("#show_list tr").remove();
var code = $.trim($("#code").val());
var currentPage = parseInt($.trim($("#currentPage").val()) == null || "" == $.trim($("#currentPage").val()) ? 1 : $.trim($("#currentPage").val()));
var totalPage = parseInt($.trim($("#totalPage").val()) == null || "" == $.trim($("#totalPage").val()) ? 1 : $.trim($("#totalPage").val()));
if(a == 1){
currentPage = currentPage + 1;
} else {
currentPage = currentPage - 1;
}
if(currentPage < 1){
currentPage = 1;
} else if(currentPage > totalPage){
currentPage = totalPage;
}
$("#currentPage").val(currentPage);
$.ajax({
url : "sy/showStockComment.html",
dataType : "JSON",
type : "post",
data : {
"code" : code,
"currentPage" : currentPage
},
success : function(data){
var $dataTable = $("#show_list");
$(data).each(function(){
$dataTable.append("<table id='table"+this.ID+"'><tr><td><img src='"+this.USER_IMG+"'></td><td id="+this.ID+" colspan='2'>"+this.COMMENT_CONTENT+"</td></tr><tr><td>"+this.USER_NAME+"</td><td>"+(this.CREATE_TIME.year+1900)+"-"+(this.CREATE_TIME.month+1)+"-"+this.CREATE_TIME.date+"<a id='zan"+this.ID+"' href='javascript:checkSupport("+this.ID+")'>赞(<span class='number'>"+this.SUPPORT_NUMBER+"</span>)</a> <a id='pl"+this.ID+"' href='javascript:showComment("+this.ID+")'>评论(<span id='pl'>"+this.COMMENT_NUMBER+"</span>)</a> <a href=javascript:showDiv('"+this.COMMENT_CONTENT+"')>转发</a></td></tr></table>");
});
},
});
}
这是HTML代码
<table id="show_list">
</table>
function init(a){
$("#show_list tr").remove();
var code = $.trim($("#code").val());
var currentPage = parseInt($.trim($("#currentPage").val()) == null || "" == $.trim($("#currentPage").val()) ? 1 : $.trim($("#currentPage").val()));
var totalPage = parseInt($.trim($("#totalPage").val()) == null || "" == $.trim($("#totalPage").val()) ? 1 : $.trim($("#totalPage").val()));
if(a == 1){
currentPage = currentPage + 1;
} else {
currentPage = currentPage - 1;
}
if(currentPage < 1){
currentPage = 1;
} else if(currentPage > totalPage){
currentPage = totalPage;
}
$("#currentPage").val(currentPage);
$.ajax({
url : "sy/showStockComment.html",
dataType : "JSON",
type : "post",
data : {
"code" : code,
"currentPage" : currentPage
},
success : function(data){
var $dataTable = $("#show_list");
$(data).each(function(){
$dataTable.append("<table id='table"+this.ID+"'><tr><td><img src='"+this.USER_IMG+"'></td><td id="+this.ID+" colspan='2'>"+this.COMMENT_CONTENT+"</td></tr><tr><td>"+this.USER_NAME+"</td><td>"+(this.CREATE_TIME.year+1900)+"-"+(this.CREATE_TIME.month+1)+"-"+this.CREATE_TIME.date+"<a id='zan"+this.ID+"' href='javascript:checkSupport("+this.ID+")'>赞(<span class='number'>"+this.SUPPORT_NUMBER+"</span>)</a> <a id='pl"+this.ID+"' href='javascript:showComment("+this.ID+")'>评论(<span id='pl'>"+this.COMMENT_NUMBER+"</span>)</a> <a href=javascript:showDiv('"+this.COMMENT_CONTENT+"')>转发</a></td></tr></table>");
});
},
});
}
这是HTML代码
<table id="show_list">
</table>
展开全部
<script>
//1、首先创建js数组
var array = new Array();
//2、通过c标签循环sinList 并生成添加到array的字符串
<c:forEach items="${sinList}" var="a">
array.push(${a}); //生成如 array.push(123)的字符串 这样前台拿到后就是js
</c:forEach>
//3、接下来就可以在台拿到array进行操作
</script>
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询