customising ajaxCFC JQuery - Error Handler

The new version of ajaxCFC that runs on jQuery is excellent and has a bunch of nifty helper functions. I have recently had the need to make the end result less developer friendly and more user friendly.

So here we go - how to catch errors with ajaxCFC without using the default error handler.

First turn off the default handler.

$.AjaxCFCHelper.setUseDefaultErrorHandler(false);
now lets set up an ajax call as per the documentation, this one will pass a categoryid of 0 to a getProductList method, and simply dump the result to screen:
$.AjaxCFC({
url: "/ajax/ecom.cfc",
method: "getProductList",
data: {"CategoryID":0},
success: function(r) {
   sDumper(r);
}
});
Now we need to tell our ajax function what to do if there is a problem, we already tell it what to do with a successful result, so why not an error?
$.AjaxCFC({
url: "/ajax/ecom.cfc",
method: "getProductList",
data: {"CategoryID":0},
error: function(r){
   //no action required },
success: function(r) {
   sDumper(r);
}
});
Its pretty obvious right? Well yes, now that we know about it. passing in r doesn't actually give us any real help, there isn't anything returned that tells us actually what went wrong. Here is a screen dump of that content:

Related Blog Entries

Comments
BlogCFC was created by Raymond Camden. This blog is running version 5.9.001.