zoukankan      html  css  js  c++  java
  • 工作笔记——一些常用函数的封装

    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
    	    })();
    

      

     

  • 相关阅读:
    网站微信登录-python 实现
    最终还是迁移到github
    理解 python 装饰器
    Git 学习之 Git Basics
    haskell 常用 函数
    jinja 2 filter 使用
    目标的牵引作用
    姨妈去世了
    OKR的理解
    无法证明的事情,和梦又有什么区别呢
  • 原文地址:https://www.cnblogs.com/MonaSong/p/5915312.html
Copyright © 2011-2022 走看看