求助大神帮改一下代码,上拉加载数据。
<!doctype html>
<html>
<head>
<%@ page contentType="text/html;charset=utf-8" %>
<% request.setCharacterEncoding("utf-8"); %>
<title>滚动加载</title>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="description" content="Write an awesome description for your new site here. You can edit this line in _config.yml. It will appear in your document head meta (for Google search results) and in your feed.xml site description.
">
<link rel="stylesheet" href="../lib/weui.min.css">
<link rel="stylesheet" href="../css/jquery-weui.css">
<link rel="stylesheet" href="css/demos.css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>
<%@ page language = "java" import = "java.sql.*"%>
<%@ page import="java.util.*" %>
<%@ page session="true" %>
<%@ page import="javax.naming.Context" %>
<%@ page import="javax.sql.DataSource"%>
<%@ page import="javax.naming.InitialContext"%>
<%@ page import="java.io.File"%>
<%
DataSource ds = null;
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
ds = (DataSource)envCtx.lookup("jdbc/MyOracle");
Connection cn=ds.getConnection();
Statement conn = cn.createStatement();
Statement conn1 = cn.createStatement();
String sql="select * from kh_main order by xh asc";
ResultSet rs=null;
rs = conn.executeQuery(sql);
int a=0;
%>
<body ontouchstart>
<h1 class="demos-title">滚动加载</h1>
<div id="list" class='demos-content-padded'>
<% while(rs.next()) {
a++;
if (a==50) break; //想首次只示50条记录,其余的记录在要加载的内容中下拉时加载
%>
<p><%=(rs.getString("khmc")== null ? "-" : rs.getString("khmc"))%></p>
<%
}
%>
</div>
<div class="weui-infinite-scroll">
<div class="infinite-preloader"></div>
正在加载
</div>
<script src="../lib/jquery-2.1.4.js"></script>
<script src="../js/jquery-weui.js"></script>
<script>
for(var a>=31;a++)
{
var loading = false;
$(document.body).infinite().on("infinite", function() {
if(loading) return;
loading = true;
setTimeout(function() {
$("#list").append("<p>要加载的第50条记录以后内容想实现每上拉一次加载50条记录,一直加载完</p>");
loading = false;
}, 1000);
});
}
</script>
<%
rs.close();
cn.close();
%>
</body>
</html>
这段jsp代码如何实现呀?