return;
}
else{
var startId=lastIndex+1;
var endId=startId+8;
$(“#count”).text(startId);
loadPhoto(startId,endId);
}
});
});
//获取图片总数
function getCountPhoto(){
$.post(“viewServer.ashx”,{“action”:”countPhoto”},function(data,status){
if(status!=”success”){
alert(“图片总数加载失败!”);
}
else{
$(“#sum”).text(data);
}
});
};
//加载图片的公共函数,索引从startid到endId
function loadPhoto(startId,endId){
$.post(“viewServer.ashx”,{“startId”:startId,”endId”:endId,”action”:”getData”},function(data,status){ //告诉后台要哪几张图片
if(status!=”success”){
alert(“小图片加载失败!”);
}
else{
getCountPhoto(); //获取图片总数
$(“#smallTr”).empty();
var photos=$.parseJSON(data); //使用json传递数据,json用着就是爽啊
for(var i=0;i<photos.length;i++){
var photo=photos[i];
var td=$(“<td ><img id='”+photo.Rownum+”‘ class=’photo’ src=’images/”+photo.ImageUrl+”‘/></td>”);
$(“#smallTr”).append(td);
}
$(“#tmpimg”).attr(“src”,”images/”+photos[0].ImageUrl);
}
//为每个小图片设置mouseover和click事件
$(“#smallTr img”).mouseenter(function(){
$(this).attr(“cursor”,”pointer”);
})
.click(function(){
$(“#count”).text($(this).attr(“id”));
$(“#tmpimg”).attr(“src”,$(this).attr(“src”));
});
});
};
//如果图片加载过慢,提示加载中。。。。
$(“#loading”).ajaxStart(function(){
$(this).show();
})
.ajaxStop(function(){
$(this).hide();
});
</script>
</head>
<body style=”text-align: center;”>
<form id=”form1″ runat=”server”>
<div id=”top” style=”text-align: center”>
<input id=”leftBtn” type=”button” />
<div id=”smallPhoto”>
<table>
<tr id=”smallTr”>
</tr>
</table>
</div>
<input id=”rightBtn” type=”button” />
</div>
<div id=”bigPhoto”>
<span style=”display:none;” id=”loading”>加载中…..</span> <br /> <img id=”tmpimg” src=”” style=”position: relative; height: 600px; width: 800px;”/>
</div>
<br />
<div id=”bottom”>
共<span id=”sum” style=”visibility: visible;”><strong>0</strong></span>张, 当前第<span id=”count” style=”visibility:visible;”><strong>0</strong></span>张










