您的位置:首页 > Web前端 > JQuery

jquery+ajax实现排名小应用

2010-12-31 15:47 344 查看

在action中读取数据库数据并做好排序,

在struts.xml中

<package name="example" extends="json-default">
<action name="test"
class="com.test">
<result type="json"></result>
</action>
</package>

使用json插件jar包jsonplugin-0.33.jar

js文件:

<script>
$(function(){
$.getJSON(‘action的url地址’,function(data){
$.each(data,function(entryIndex,entry){
for(var i=0;i<$(entry).size();i++){
var html="<tr height='26'>";
html+="<td width='52' align='center' valign='middle'>"+(i+1)+'</td>';
html+="<td width='100' align='center' valign='middle'>"+(entry[i].userName.substring(0,2)+"***")+"</td>";
html+="<td width='125' align='center' valign='middle'>"+entry[i].voteAccount+'</td>';
html+='</tr>';
$(html).appendTo($('#ccbXc'));
}
});
});
});

</script>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: