• ajax操作登录


    js文件中的内容(ajax.operate.js)

    ;
    (function ($, window) {
    var _ajaxOperate = window.ajaxOperate || {};

    _ajaxOperate.callback = false;

    _ajaxOperate.defaultOpts = {
    callback:false,
    clearCallback:false,
    formParams:{}
    };

    var _ajaxLoginShow = function (opts) {
    opts = $.extend(this.defaultOpts,opts);
    if (opts.clearCallback) this.callback = false;
    if (opts.callback) this.callback = opts.callback;
    var url = "/ajax_quick_login.html";
    $('#ajaxLoginFormWrapper .accbtn').removeClass("onclick");
    $('#ajaxLoginFormWrapper .accbtn').removeAttr("disabled");
    $.get(url,opts.formParams, function (data) {
    $('#ajaxLoginFormWrapper').remove();
    $("body").append(data);
    });
    };
    _ajaxOperate.quickLogin = _ajaxLoginShow;

    var _ajaxLoginHandle = function ($form) {
    var self = this,
    url = '/doajaxlogin.html';
    $('#ajaxLoginFormWrapper .accbtn').addClass("onclick");
    $('#ajaxLoginFormWrapper .accbtn').attr("disabled", "disabled");
    $.post(url, $form.serialize(), function (data) {
    if (data.status != 1) {
    $('#ajaxLoginFormWrapper').addClass('err').find('div.errorBox').html(data.message).show(300);
    $('#ajaxLoginFormWrapper .accbtn').removeClass("onclick").removeAttr("disabled");
    } else {
    $('#ajaxLoginFormWrapper').remove();
    $('.step3Tips').size() > 0 && $('.step3Tips').hide();
    self.callback != false && self.callback.call(self, data);
    }
    }, 'json');
    };
    _ajaxOperate.quickLoginHandle = _ajaxLoginHandle;

    var _ajaxRegShow = function (opts) {
    opts = $.extend(this.defaultOpts,opts);
    if (opts.clearCallback) this.callback = false;
    if (opts.callback) this.callback = opts.callback;
    var url = "/ajax_quick_reg.html";
    $('#ajaxLoginFormWrapper .accbtn').removeClass("onclick");
    $('#ajaxLoginFormWrapper .accbtn').removeAttr("disabled");
    $.get(url, function (data) {
    $('#ajaxLoginFormWrapper').remove();
    $("body").append(data);
    });
    };
    _ajaxOperate.quickReg = _ajaxRegShow;

    var _ajaxRegHandle = function ($form) {
    var self = this,
    url = '/doajaxregister.html';
    $('#ajaxLoginFormWrapper .leftForm ul li em.tips').hide();
    $('#ajaxLoginFormWrapper .accbtn').addClass("onclick").attr("disabled", "disabled");
    $.post(url, $form.serialize(), function (data) {
    if (data.status != 1) {
    $('#ajaxLoginFormWrapper .leftForm ul li em.'+data.field).html(data.message).show();
    //$('#ajaxLoginFormWrapper').addClass('err').find('div.errorBox').html(data.message).show(300);
    $('#ajaxLoginFormWrapper .accbtn').removeClass("onclick").removeAttr("disabled");
    } else {
    $('#ajaxLoginFormWrapper').remove();
    self.callback != false && self.callback.call(self, data);
    }
    }, 'json');
    };
    _ajaxOperate.quickRegHandle = _ajaxRegHandle;

    window.ajaxOperate = _ajaxOperate;

    })(jQuery, window);
    $(document).keypress(function (e) {
    var key = e.which;
    if (key == 13) {
    if ($('#ajaxLoginFormWrapper').size() > 0) {
    $('#ajaxLoginFormWrapper').find('input.accbtn').trigger('click');
    return false;
    }
    }
    });

     里面会展示登录html

    然后点击登录操作(赋值回调函数)

    ajaxOperate.callback != false && ajaxOperate.callback.call(ajaxOperate, data);

    操作中ajax操作后的回调方法书写

    ajaxOperate.quickLogin({callback: function (dataHeader) {
    doPost($this, url, postData, extralOptions);
    return false;
    }});

  • 相关阅读:
    高并发的epoll+线程池,epoll在线程池内ehyyngpChinaUnix博客
    用vim处理字符的大小写转换
    jabberd14 XMPP/Jabber server daemon
    thriftmissingguide/
    高并发的epoll+多线程ehyyngpChinaUnix博客
    大讲堂
    [基于Epoll内置LeaderFollower服务端实现, 已可达50万echo qps(全新支持Lua啦)] C/C++ ChinaUnix.net
    来说说epoll+线程池
    boost高并发网络框架+线程池ehyyngpChinaUnix博客
    高并发的epoll+线程池,业务在线程池内ehyyngpChinaUnix博客
  • 原文地址:https://www.cnblogs.com/xingmeng/p/3899672.html
Copyright © 2020-2023  润新知