0

limit when implement zAu.ajaxErrorHandler

asked 2015-05-12 13:13:50 +0800

hiepgau gravatar image hiepgau
11 2

Feature zAu.ajaxErrorHandler for customize handle Au request is great. thanks @jumperchen for implement it.

I encounter some limit when use implement ajaxErrorHandler, maybe by my implement or need improve ajaxErrorHandler, please let me a advice.

current code for handle zk error in function onResponseReady as below.

if (typeof zAu.ajaxErrorHandler == 'function') {
    ajaxReqTries = zAu.ajaxErrorHandler(req, rstatus, req.statusText, ajaxReqTries);
    if (ajaxReqTries > 0) {
        ajaxReqTries--;
        ajaxReqResend(reqInf, zk.resendTimeout);
            return;
    }
} else {
    switch (rstatus) { 
        default:
            if (!ajaxReqTries) break;

        case 12002: 
        case 12030: 
        case 12031:
        case 12152: 
        case 12159:
        case 13030:
        case 503: 
            if (!ajaxReqTries) ajaxReqTries = 3; 
        if (--ajaxReqTries) {
            ajaxReqResend(reqInf, zk.resendTimeout);
            return;
        }
    }

    if (!reqInf.ignorable && !zk.unloading) {
        var msg = req.statusText;
        if (zAu.confirmRetry('FAILED_TO_RESPONSE', rstatus+(msg?': '+msg:''))) {
            ajaxReqTries = 2; 
            ajaxReqResend(reqInf);
            return;
        }
    }
}
  1. ajaxReqResend and reqInf is a private member, so i can't reference them in my ajaxErrorHandler function.
  2. i just want extent default error handle, add some my customize for some error code, but leave other error code default. but i can't or i must copy default code. even i copy default code (from "else {switch (rstatus) {" to end), because limit description at 1, i can't redo step check reqInf.ignorable
delete flag offensive retag edit
Be the first one to answer this question!
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2015-05-12 13:13:50 +0800

Seen: 12 times

Last updated: May 12 '15

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More