标签:oca window div enc llb fun obj ++ return
$.ajax 常用的套路
(function(){ window.webApi = new Object(); webApi.get = function(url,data,callback){ $.ajax({ type:‘GET‘, data: data, url: url, success: function(result){ callback && callback(result) } }) }; webApi.formPost = function(url,data,callback){ $.ajax({ type:‘POST‘, data: data, contentType:‘application/x-www-form-urlencoded‘, url: url, success: function(result){ callback && callback(result) } }) }; webApi.jsonPost = function(url,data,callback){ $.ajax({ type:‘POST‘, data: JSON.stringify(data), contentType:‘application/json‘, url: url, success: function(result){ callback && callback(result) } }) }; window.getRequest = function(){ var httpUrl = location.href; //获取url中‘?‘符后的字串 var url = ‘?‘ + httpUrl.split(‘?‘)[1]; var theRequest = {}; if (url.indexOf(‘?‘) != -1) { var str = url.substr(1); var strs = str.split(‘&‘); for (var i = 0; i < strs.length; i++) { theRequest[strs[i].split(‘=‘)[0]] = decodeURIComponent(strs[i].split(‘=‘)[1]); } } return theRequest; } })()
标签:oca window div enc llb fun obj ++ return
原文地址:https://www.cnblogs.com/mingzhanghui/p/9397640.html