代码分析
来源:互联网 发布:开淘宝店铺成功案例 编辑:程序博客网 时间:2024/04/30 07:52
- QueryDataRows——从服务器查询数据:需要的参数msg
function ciQueryDataRows(msg, successfun, errorfun) { showMessage("正在从服务器查询数据..."); msg = ciCheckMsg(msg); $.ajax({ url : JsonSvr.ciJsonServerHttpPath, type : "POST", cache : false, async : false, data : "msg=" + $.base64.encode(encodeURI(JSON.stringify(msg))), dataType : "json", contentType : "application/x-www-form-urlencoded; charset=UTF-8", success : function(data) { showMessage(""); try { if (successfun != null) { successfun(data) }; } catch (e) { showMessage( "运行错误[CIF-30210]ciQueryDataRows->successfun回调错误:" + e, -1, window.JsonSvr.errorColor); } }, error : function(xhr, error, settings, errorType) { ajaxErrorHandler(xhr, error, settings, errorType, errorfun) } }); }
2.按指定的参数与服务器进行通信,UpdateDataRow
// 按指定的参数从服务器获取数据function ciUpdateDataRow(citableid, citblname, clientcmd, fldnames, fldvals, citblwhecls, addtional, successfun, errorfun) { showMessage("正在向服务器更新数据..."); var msg = { citableid : citableid, citblname : citblname, citblwhecls : citblwhecls, clientcmd : clientcmd, fldnames : fldnames, fldvals : fldvals }; $.ajax({ type : "POST", url : JsonSvr.ciJsonServerHttpPath, cache : false, async : false, data : "msg=" + $.base64.encode(encodeURI(JSON.stringify(msg))), dataType : "json", contentType : "application/x-www-form-urlencoded; charset=UTF-8", success : function(data) { ajaxUpdateSucc(data, successfun, errorfun) }, error : function(xhr, error, settings, errorType) { ajaxErrorHandler(xhr, error, settings, errorType, errorfun) } });}
3.数据更新成功后的处理方法
// 数据更成功后的处理方法function ajaxUpdateSucc(data, successfun, errorfun) { if (successfun != undefined) try { successfun(data); } catch (ex) { showMessage("运行错误[CIF-30200]ciUpdateDataRow->successfun回调错误:" + ex, -1, window.JsonSvr.errorColor); } var result = data.result; if (result.issucc != "OK") {//如果返回的参数不是ok showMessage(result.errmessage, -1, window.JsonSvr.errorColor); } else { if (result.clientcmd == 'A') showMessage("添加数据成功!", 3000); else if (result.clientcmd == 'D') showMessage("删除数据成功!", 3000); else if (result.clientcmd == 'U') showMessage("数据更新成功!", 3000); else showMessage(""); } // 开发人员数据更新需要,人工刷新界面,调用 ciGetDataRow(citableid);}
人工刷新界面,调用ciGetDataRow(citableid)
function ciGetDataRow(citable, successfun, errorfun) { ciGetDataRows(-1, citable, successfun, errorfun);}
G的命令进行分页处理
function ciGetDataRow(citable, successfun, errorfun) { ciGetDataRows(-1, citable, successfun, errorfun);}function ciGetDataRows(citblrowid, citable, successfun, errorfun) { showMessage("正在从服务器加载数据..."); var citableId = ""; if (typeof citable == "string") { citableId = citable; citable = $("#" + citable); citable = $(citable).get(0); }else{ citableId =$(citable).attr("id"); } if ($(citable).length == 0) { showMessage("运行错误[CIF-4002]:ciGetDataRows函数指定的参数citable(ID=“" + $(citable).attr("id") + "”)在页面中没有找到,请修改后再试!", -1, window.JsonSvr.errorColor); return; } var msg = { clientcmd : "G", citableid : $(citable).attr("id"), citblrowid : citblrowid, cipagesize : $(citable).attr("cipagesize"), cipageindex : $(citable).attr("cipageindex"), citblselcls : $(citable).attr("citblselcls"), citblfrmcls : $(citable).attr("citblfrmcls"), citblwhecls : $(citable).attr("citblwhecls"), citblordcls : $(citable).attr("citblordcls") }; msg = ciCheckMsg(msg); $.ajax({ url : JsonSvr.ciJsonServerHttpPath, type : "POST", cache : false, async : false, data : "msg=" + $.base64.encode(encodeURI(JSON.stringify(msg))), dataType : "json", contentType : "application/x-www-form-urlencoded; charset=UTF-8", success : function(data) { ajaxGetDatarowsSucc(data, successfun) }, error : function(xhr, error, settings, errorType) { ajaxErrorHandler(xhr, error, settings, errorType, errorfun) } });}
分页数据从服务器获取成功后的方法
4.消息显示框
// 显示消息框function showMessage(msg, fadeTime, bgcolor) { if (!fadeTime) fadeTime = 0; if (!bgcolor) bgcolor = "#336600"; // 确保消息框的存放位置,msgwarp是msg的包装集,append方法追加的可以是jquery对象、string、element var msgwarp = $("#divcimsgwarp"); if (msgwarp.length == 0) { msgwarp = $("<div id=\"divcimsgwarp\" style=\"position:absolute;top:0px;right:0px;\"></div>"); $(document.body).append(msgwarp); } var msgCount = msgwarp.find("div").length; var divcimsgid = "divcimsg" + msgCount; // fadeTime==0时在默认的信息框显示,否则创建新的信息框 if (fadeTime == 0) { divcimsgid = "divcimsg"; } var divcimsg = $("#" + divcimsgid); if (divcimsg.length > 0) divcimsg.remove(); divcimsg = $("<div class='cimessage' id=\"" + divcimsgid + "\" title=\"点击关闭显示。\" style=\"background-color:" + bgcolor + ";\" onclick=\"$(this).remove();\"></div>"); msgwarp.append(divcimsg); divcimsg.html(msg); if (msg == "") { divcimsg.remove(); } else { divcimsg.slideDown("fast", function() { if (fadeTime == 0) {//没有设定时间的话,五秒淡出 divcimsg.fadeOut(5000); } else if (fadeTime > 0) {//指定时间,对象移除 divcimsg.fadeOut(fadeTime, function() { $(this).remove(); }); } }); }}
备注:1.slideDown(speed,[callback])// 2.fadeOut(speed,[callback])参数1--speed (String,Number) :三种预定速度之一的字符串("slow", "normal", or "fast")或表示动画时长的毫秒数值(如:1000)参数2:--callback (FunctionFunction) : (可选) 在动画完成时执行的函数
0 0
- 分析代码
- 代码分析
- 分析代码
- 代码分析
- 分析代码
- 代码分析
- 代码分析
- 代码分析
- butterknife源码分析:代码分析
- Bittorrent 精彩代码分析
- Duwamish代码分析篇
- 井字棋游戏 代码分析
- VC6启动代码分析
- Duwamish代码分析篇
- 定时器代码分析
- Duwamish -- 代码分析篇
- 264代码分析
- qmail-send代码分析
- 将某列合并成字符串
- ubuntu 挂在smb服务器的方法
- PAT乙级 部分A+B
- 怎么解决BarTender因为未检测到IIS安装失败的问题
- Android WebRTC 音视频开发(二)-- webrtcdemo介绍
- 代码分析
- myeclipse序列号注册码生成Java代码 MyEclipseGen
- UE4 添加多人联机功能
- 华为oj 初级 iNOC产品部-杨辉三角的变形
- ubuntu14.04 下mysql 主从配置
- 《在唐诗里孤独漫步》读后感
- swipeRefresh下拉刷新索引越界解决方案
- Android WebRTC 音视频开发总结(三)-- 信令服务和媒体服务
- HTTP API网关选择之一Kong介绍