Content in the JS file (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. Callback allback) 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 ){
Certificate ('{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. Callback allback) 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 ();
// Certificate ('{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;
}
}
});
It will show the login html
Then click the logon operation (assign a value to the callback function)
Ajaxoperate. callback! = False & ajaxoperate. Callback. Call (ajaxoperate, data );
Callback method writing after Ajax operation in Operation
Ajaxoperate. quicklogin ({callback: function (dataheader ){
Dopost ($ this, URL, postdata, extraloptions );
Return false;
}});