工作笔记——一些常用函数的封装
发布日期:2021-10-23 09:05:17 浏览次数:2 分类:技术文章

本文共 1556 字,大约阅读时间需要 5 分钟。

1、ajax

jQuery.ax=function(url, data, async, type, dataType, successfn, errorfn) {        async = (async==null || async=="" || typeof(async)=="undefined")? "true" : async;        type = (type==null || type=="" || typeof(type)=="undefined")? "post" : type;        dataType = (dataType==null || dataType=="" || typeof(dataType)=="undefined")? "json" : dataType;        data = (data==null || data=="" || typeof(data)=="undefined")? {"date": new Date().getTime()} : data;        $.ajax({            type: type,            async: async,            data: data,            url: url,            dataType: dataType,            success: function(d){                successfn(d);            },            error: function(e){                errorfn(e);            }        });    };

2、href参数 

var param = (function getParam(){	        var href = window.location.href;	        var id = null;	        var param = {};	        if(href.indexOf('?')>-1){	            id = href.substring(href.indexOf('?')+1);	            if(id.indexOf('&&')>-1){	                console.log(0)	                $.each(id.split('&&'),function(i,item){	                    var info = item.split('=');	                    var cur = info[0];	                        param[cur]=info[1];               	                })	            }	            else{	                var list = id.split('=');	                var index = list[0];	                    param[index]=list[1]; 	            }            	        }	        return param	    })();

  

 

转载于:https://www.cnblogs.com/MonaSong/p/5915312.html

转载地址:https://blog.csdn.net/weixin_30549657/article/details/95802793 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:node初识——node中的require方法与require.js的区别
下一篇:AMIO编辑器开发(九):键盘的左右键交互

发表评论

最新留言

关注你微信了!
[***.104.42.241]2024年03月31日 00时01分30秒