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

  • 相关阅读:
    如何正确使用Windows的Ping命令
    Web设计里的软件工程思想
    台风麦莎在8月6日凌晨登陆浙江台州
    多图展示:微软IE1.0至7.0界面回顾
    Windows XP减肥行动
    微软正版验证启动24小时内被攻破
    如果你想成功,35岁前必须做好的十件事情
    Informix数据备份小技巧
    crontab命令使用浅析
    Windows Vista公布硬件要求
  • 原文地址:https://www.cnblogs.com/andydao/p/5076457.html
Copyright © 2011-2022 走看看