gistfile1.txt var _url="/ajaxDemo/StudentUsersServlet?type=";var pageIndex=1;var pageSize=10;var maxIndex=1;var list;$(function(){getData();});function getData(){$.post(_url+"getAll",{},function(data){list=$.parseJSON(data);pagHref();})};fu
var _url="/ajaxDemo/StudentUsersServlet?type="; var pageIndex=1; var pageSize=10; var maxIndex=1; var list; $(function(){ getData(); }); function getData(){ $.post(_url+"getAll",{},function(data){ list=$.parseJSON(data); pagHref(); }) }; function updateMSg(i){ var sno=list[i][0].studentsSno; var html = "用户名:
"; html+="密 码:
" html+="学 号:"+sno+"
" html+="姓 名:" $.jBox(html,{bottomText:"确定!" ,title: "编辑用户信息",submit:function(){ var name=$("#username").val(); var pwd=$("#password").val(); var sname=$("#sname").val(); $.post(_url+"updata",{"username":name,"password":pwd,"sname":sname,"studentsSno":sno},function(data){ if(data>1){ $.jBox("修改成功!",{bottomText:"开心!",title:"提示",submit:function(){ window.setTimeout(function () { $.jBox.tip('想笑就笑!', 'success');getData();},100); }}); }else $.jBox("修改失败,请联系管理员!",{bottomText:"难过!",title:"提示",submit:function(){ window.setTimeout(function () { $.jBox.tip('孩子!', 'success'); },100); }}); }) }}); } function deleteUsers(i){ var submit = function (v, h, f) { if (v == 'ok') { $.jBox.tip("正在删除数据...", 'loading'); $.post(_url+"delete",{"StudentsSno":list[i][0].studentsSno},function(data){ if(data>0){ // 模拟2秒后完成操作 window.setTimeout(function () { $.jBox.tip('删除成功。', 'success');getData(); },parseInt(Math.random()*2000)); }else $.jBox("修改失败,请联系管理员!",{bottomText:"难过!"},{title:"提示"},function(){}); }); } else if (v == 'cancel') { // 取消 window.setTimeout(function () { $.jBox.tip('已取消!', 'success'); },200); } return true; //close }; $.jBox.confirm("确定要删除数据吗?", "提示", submit); } function pagHref(){ maxIndex=list.length%10==0?list.length/10:(list.length-list.length%10)/10+1; var tbody=$("#tbody"); tbody.html(""); $("#index").val(pageIndex); $("#pageIndex").html(pageIndex); $("#maxIndex").html(maxIndex); for(var i=pageSize*(pageIndex-1);i<(pageIndex*pageSize