//ajax封装 function ajaxManage(options) { var defaults = { url: "", data: {}, type: "POST", async: false, dataType: "json", success: function (result) { return result; } }; var opts = $.extend(defaults, options); $.ajax({ type: opts.type, url: opts.url, data: opts.data, dataType: opts.dataType, async: opts.async, success: opts.success, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log(opts.url + " error:"); console.log(XMLHttpRequest); console.log(textStatus); console.log(errorThrown); } }); } //生产guid function guid() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); }); } function GetUrlParam(key) { // 获取参数 var url = window.location.search; // 正则筛选地址栏 var reg = new RegExp("(^|&)" + key + "=([^&]*)(&|$)"); // 匹配目标参数 var result = url.substr(1).match(reg); //返回参数值 return result ? decodeURIComponent(result[2]) : ""; } function getPoint(obj) { //获取某元素以浏览器左上角为原点的坐标 var t = obj.offsetTop; var l = obj.offsetLeft; while (obj = obj.offsetParent) { t += obj.offsetTop; //叠加父容器的上边距 l += obj.offsetLeft; //叠加父容器的左边距 } return { top: t, left: l }; }