日期:2014-05-16  浏览次数:20409 次

Jpage分页+Hibernate+Ajax+jquery+JSON通用技术<二>

?

6.为使界面美观使用JQuery

<%@ page language="java" pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
??? <title>客户</title>
??? <script type="text/javascript" src="${basePath }ui/common/script/jquery-1.3.2.min.js"></script>
??? <script type="text/javascript" src="${basePath }ui/common/script/jquery.corners.min.js"></script>-
??? <link href="${basePath}ui/client/css/styles.css" rel="stylesheet" type="text/css">
?????? <!-- *************************************************************************************************************************** -->
?????? <link rel="stylesheet" type="text/css" href="${basePath }ui/common/jpage/css/jpage.css"/>
????? <script type="text/javascript">
??? list();

/*******************************删除一个对象时运行*************************************/
function ajaxDel(clientID)
?? {
?? if(confirm("确定要删除吗?")){
??? $.ajax({
???? type: "POST",
???? url: "${basePath}client.do?method=dodel&clientID="+clientID,
???? error: function(){
????? $("#info").val("服务器繁忙,请稍后重试...");
???? },
???? success: function(msg){
????? if(msg=="err")
????? {
?????? ?? $("#info").val("服务器繁忙,数据删除失败,请稍后重试...");
?????? }
?????? else{
?????? ?? play();
?????? }
????? list();
???? }
??? });
??? }
?? }

/*************************删除多个对象时运行*******************************************/
?? function ajaxDelAll(clientID)
?? {
??? $.ajax({
???? type: "POST",
???? url: "${basePath}client.do?method=dodelmore&clientID="+clientID,
???? error: function(){
????? $("#info").val("服务器繁忙,请稍后重试...");
???? },
???? success: function(msg){
????? if(msg=="err")
????? {
?????? ?? $("#info").val("服务器繁忙,数据删除失败,请稍后重试...");
?????? }
?????? else
?????? {
?????? ??? play();
?????? ??? list();
?????? }
???? }???
??? });
?? }
/***************************************************************************************/???
??

function list() {
??
?? /*方法名称*/
?? var method;

?? /*列表容器*/
?? var content;
??
?? /*加载初始化事件*/
?? ajax();
??
?? /*绘制列表*/
?? function draw(json)
?? {
??? content = '<table width="100%" cellpadding="0" cellspacing="0" style="margin: 0px;">';
????? ?? content += '<tr align="center" class="default_pgToolbar">';
??????? /*绘制表头内容*/
??????? content += '<td width="40"><input type="checkbox" id="allchk"></input></td>';
??????? content += '<td width="100">客户名称</td>';
??????? content += '<td width="100">电话</td>';
??????? content += '<td width="100">负责人</td>';
??????? content += '<td width="100">操作</td>';
???? ?? content += '</tr>';
???? ??
???? ?? /*绘制数据*/
??? for(var i=0; i<json.list.length; i++)
??? {
???? content += '<tr align="center" style="border-bottom: 1px solid #88B4FF;">';
???? content += '<td><input type="checkbox" id="' + json.list[i].clientID + '" name="chk"/></td>';
???? content += '<td><a href="${basePath}client.do?method=todetail&clientID=' + json.list[i].clientID + '">' + json.list[i].name + '</a></td>';
???? content += '<td>' + json.list[i].phone + '</td>';
???? content += '<td>' + json.list[i].user.name+ '</td>';
???? content += '<td><a href="${basePath}client.do?met