Error Handling - Different Error Display Pages


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?


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’;–tries-to-read-the-xmlhttp-request-header-and-determine-if-req—

Luis F. Majano
Ortus Solutions, Corp

ColdBox Platform:
Linked In:
IECFUG Manager: