$.extend({ /** * 分页 * @page * @divId 分页div位置ID * @method 点击处理函数 * */ uiPage: function(page,divId,method){ $(divId).empty(); var content =''; $(divId).append(content); }, emptyText:function(ui){ var content = '
暂无相关数据
'; $("#"+ui).append(content); }, emptyTextMobile:function(ui){ var content = '
---- 暂无相关数据 ----
'; $("#"+ui).append(content); }, isEmpty: function isEmpty(obj) { if (obj == "undefined") { return true; } else if (obj == null) { return true; } else if (obj === "") { return true; } else if (obj === "null") { return true; } else { return false; } }, simpleGet : function (url, data, result, async,errorMethod) { $.simpleAjax(url, "get", data, result, async,false,errorMethod); }, simplePost:function (url, data, result, async, errorMethod) { this.simpleAjax(url, "post", data, result, async, false, errorMethod); }, simpleAjax:function(url, type, data, result, async, errorMethod){ if ($.isEmpty(async)) async = true; //默认异步加载 if ($.isEmpty(data)) data = {}; var contentType = "application/x-www-form-urlencoded"; if (!$.isEmpty(data.contentType)) { contentType = data.contentType; delete data.contentType; if (contentType == 'application/json;charset=utf-8') { data = data._list ? JSON.stringify(data._list) : JSON.stringify(data); } } $.ajax({ url: url, data: data, dataType: "json", type: type, async: async, contentType: contentType, success: function success(obj) { if (obj.code === '0') { result(obj); }else { if (errorMethod) { errorMethod(obj) }else{ alert(obj.desc); } } }, beforeSend: function beforeSend(xhr) { xhr.setRequestHeader("domain",'http://www.qcwljs.com/static/www.qcwljs.com'); }, error: function error() { alert("网络错误,请联系管理员"); } }); } });