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

      

     

  • 相关阅读:
    【Linux】ZeroMQ 在 centos下的安装
    ZeroMQ下载、编译和使用
    在Linux系统上安装Git
    Linux下python2.7安装pip
    [Tyvj1474]打鼹鼠
    [BZOJ2908]又是nand
    [SPOJ375]Qtree
    浅谈算法——树链剖分
    [BZOJ5368/Pkusc2018]真实排名
    [FJOI2007]轮状病毒
  • 原文地址:https://www.cnblogs.com/MonaSong/p/5915312.html
Copyright © 2011-2022 走看看