各位高手,下面是我的读取json数据并在页面返回了一个数据表格,怎么将表格中的数据使用走马灯的方式显示在页面上呢,而不是表格方式了,求救各位高手帮忙!!!!
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%
response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
%>
<html>
<head>
<title>股票信息</title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<script type="text/javascript" src="/portalExternal/js/jquery.js"
charset="UTF-8"></script>
<script type="text/javascript">
$(document).ready(function() {
$.ajax({
url:"/portalExternal/a.json",
type:"GET",
dataType:'json',
success:function(data){
/*alert(data);*/
wirteHtml(data);
},
error:function(){
alert("error");
}
});
});
function wirteHtml(data){
//var list = $.parseJSON(data);
var htmlstr="";
$.each(data, function(index,value){
var row = $("#template_0").clone();
row.find("#stockId").text(value.stockId);
row.find("#name").text(value.name);
row.find("#dvalence").text(value.dvalence);
row.find("#gdvalue").text(value.gdvalue);
row.find("#gdrange").text(value.gdrange);
row.find("#createDate").text(value.createDate);
row.appendTo("#table");
});
}
</script>
</head>
<body>
<div id="stockMessage">
<table id="table" border="1">
<thead>
<td>
股票ID
</td>
<td>
股票名称
</td>
<td>
成交价
</td>
<td>
涨跌值
</td>
<td>
涨跌幅
</td>
<td>
当前时间
</td>
</thead> <tbody>
<tr id="template_0">
<td id="stockId"></td>
<td id="name"></td>
<td id="dvalence"></td>
<td id="gdvalue"></td>
<td id="gdrange"></td>
<td id="createDate"></td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%
response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
%>
<html>
<head>
<title>股票信息</title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<script type="text/javascript" src="/portalExternal/js/jquery.js"
charset="UTF-8"></script>
<script type="text/javascript">
$(document).ready(function() {
$.ajax({
url:"/portalExternal/a.json",
type:"GET",
dataType:'json',
success:function(data){
/*alert(data);*/
wirteHtml(data);
},
error:function(){
alert("error");
}
});
});
function wirteHtml(data){
//var list = $.parseJSON(data);
var htmlstr="";
$.each(data, function(index,value){
var row = $("#template_0").clone();
row.find("#stockId").text(value.stockId);
row.find("#name").text(value.name);
row.find("#dvalence").text(value.dvalence);
row.find("#gdvalue").text(value.gdvalue);
row.find("#gdrange").text(value.gdrange);
row.find("#createDate").text(value.createDate);
row.appendTo("#table");
});
}
</script>
</head>
<body>
<div id="stockMessage">
<table id="table" border="1">
<thead>
<td>
股票ID
</td>
<td>
股票名称
</td>
<td>
成交价
</td>
<td>
涨跌值
</td>
<td>
涨跌幅
</td>
<td>
当前时间
</td>
</thead> <tbody>
<tr id="template_0">
<td id="stockId"></td>
<td id="name"></td>
<td id="dvalence"></td>
<td id="gdvalue"></td>
<td id="gdrange"></td>
<td id="createDate"></td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货