Error Handling - Different Error Display Pages

Hi,

I am wondering if there is a (universal?) way to detect if something
is loading through AJAX in here. We have a custom error page for when
the user encounters an error but we want to have something different
display when the erroring page is loaded in AJAX.

We already had the idea of putting an "&isJS=1" flag in the JS post/
gets but figured that would be too hard to implement in already
existing code and to have everyone remember to put that in when
building stuff in the future - does anyone know a good way to
accomplish this across the board?

Thanks,
Bridget

If you run your ajax calls through a coldbox proxy (and you should), you
can do event.isProxyRequest()

Curt Gratz
Computer Know How
Coldbox Alliance Partner

You can use ‘getHTTPRequestData()’ and look for the ‘XMLHttpRequest’ header. All the populate ajax libraries (including my prefered jQuery) will append that header.

var httpData = getHTTPRequestData();
var isAjax = structKeyExists(httpData.headers, ‘X-Requested-With’) && httpData.headers[‘X-Requested-With’] == ‘XMLHttpRequest’;

http://coldbox.assembla.com/spaces/coldbox/tickets/1084-new-requestcontext-method-isajax()–tries-to-read-the-xmlhttp-request-header-and-determine-if-req—

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com