zoukankan      html  css  js  c++  java
  • js ajax

    //通用请求入口
    $.extend({
        ajaxReq: function(options){
            var url     = options.url || '';
            var type        = options.type|| 'get';
            var data    = options.data|| {};
            var dataType    = options.dataType || 'json';
            var async       = options.async || true;
            var successFn    = options.succuss || null;    
            var error     = option.error || null;
            var beforeFn    = option.beforeSend || null;
            var complete  = option.complete || null;
            $.ajax({
                url : url,
                type: type,
                data: data,        
                dataType : dataType,
                beforeSend:function(){                
                    if(beforeFn){
                       beforeFn.call(null, Array.prototype.slice.call(arguments));
                    }               
                },        
                complete  :function(){
                    if(complete){
                         complete.apply(null, Array.prototype.slice.call(arguments));
                    }
                },
                success   :function(msg){
                   if(successFn){
                      successFn.call(null, msg);
                   }
                },
                error     :function(){
                   if(error){
                     error.apply(null, Array.prototype.slice.call(arguments));
                   }
                }
               }
            });
        }
    });

  • 相关阅读:
    使脱排油烟机能够听懂你的话(超级简单的方法)
    解决手机无法连接【小米AI音箱】播放音乐问题
    相机稳定器使用注意点
    Scrapy基本命令
    Linux环境下的Scala环境搭建
    Linux基本操作
    MySQL常用操作
    PySpark笔记
    Linux环境下配置及启动Hadoop(伪集群)
    idea: unable to import maven project
  • 原文地址:https://www.cnblogs.com/andydao/p/5076457.html
Copyright © 2011-2022 走看看