Added JS exception dialog for failed ajax calls

All failed ajax calls in the app will display an exception dialog.
This is achieved using a global listener to "ajaxError".
The dialog will show the exception returned by the server in JSON format
with a stack trace if available.

Fixes #5226