CNET always returns response code 200 for it's pages, even when they are errors. This presents a problem for any ajax framework you might be using as your ajaxer will always think the page is returning 200, even if it's not.

I wrote a quick extention for the Mootools framework as part of my forthcoming release of the CNET framework that handles this problem for you and adds some functionality to Mootools ajax class.

JavaScript:
Ajax.implement({
    responseIsSuccess: function(){
        if(this.transport.status != undefined && (this.transport.status <200 || this.transport.status>= 200)){
            return false;
        }
    if(this.transport.responseText.indexOf("COMPONENT_RESPONSE_CODE=200")> 0)
        return true;
    return false
    },
    responseIsFailure: function(){
    return !this.responseIsSuccess();      
    },
    onStateChange: function(){
        if (this.transport.readyState == 4 && this.responseIsSuccess()){
            if (this.options.update) $(this.options.update).setHTML(this.transport.responseText);
            this.options.onComplete.pass([this.transport.responseText, this.transport.responseXML], this).delay(20);
            if (this.options.evalScripts) this.evalScripts.delay(30, this);
            this.transport.onreadystatechange = Class.empty;
            this.callChain();
        } else if(this.responseIsFailure()) {
            if($type(this.options.onFailure)=='function') this.options.onFailure();
        }
    }
});

drag to resize


This hasn't been QAed yet, so I may need to tweak it.

It adds responseIsSuccess() and responseIsFailure(), and finally it adds as an excepted parameter to be passed in an onFailure function that will execute it if it fails. Example usage:

JavaScript:
new ajax(url, {update: divIdToUpdate, method: 'get', parameters: ..., evalScripts:true, onFailure:errorHandlerFunction});

drag to resize


This will be available on every page on Redball when the new framework launches.