SHOW:
|
|
- or go back to the newest paste.
| 1 | Ajax.Responders.register({
| |
| 2 | onCreate: function() {
| |
| 3 | new Effect.Appear('ajax_loader', { duration: 0.3, to: 0.5 });
| |
| 4 | }, | |
| 5 | onComplete: function(request, transport, json) {
| |
| 6 | if (0 == Ajax.activeRequestCount) {
| |
| 7 | new Effect.Fade('ajax_loader', { duration: 0.3, from: 0.5 });
| |
| 8 | } | |
| 9 | if(!request.success()) {
| |
| 10 | var errorMapping = $H({
| |
| 11 | 400: ['Bad Request', 'The request contains bad syntax or cannot be fulfilled.'], | |
| 12 | 401: ['Authorization Required', 'You need to authenticate to access this page.'], | |
| 13 | 403: ['Forbidden', 'The request was a legal request, but the server is refusing to respond to it.'], | |
| 14 | 404: ['Page Not Found', 'The requested resource could not be found.'], | |
| 15 | 405: ['Method Not Allowed', 'A request was made of a resource using a request method not supported by that resource; for example, using GET on a form which requires data to be presented via POST, or using PUT on a read-only resource.'], | |
| 16 | 406: ['Not Acceptable', 'The action you tried to perform on this resource was considered unacceptable.'], | |
| 17 | 415: ['Unsupported Media Type', 'The media type you are requesting is unsupported.'], | |
| 18 | 422: ['Unprocessable Entity', 'The request was well-formed but was unable to be followed due to semantic errors.'], | |
| 19 | 500: ['Application Error', 'An error occurred in the application code. Report sent.'], | |
| 20 | 503: ['Service not available', 'The webserver did not respond to the request.'], | |
| 21 | 505: ['HTTP Version Not Supported', 'The requested version is not available on this server.'] | |
| 22 | }); | |
| 23 | ||
| 24 | var errorMessage = errorMapping.get(transport.status) || ['Unknown Error', 'An error occurred, but could not be determined correctly.']; | |
| 25 | ||
| 26 | if (transport.responseJSON && transport.responseJSON.error) | |
| 27 | errorMessage = [transport.responseJSON.error.title, transport.responseJSON.error.message] | |
| 28 | ||
| 29 | var notifyUser = new GrowlNotifier({
| |
| 30 | title: errorMessage[0], | |
| 31 | message: errorMessage[1], | |
| 32 | image: "/images/elements/growl_warning.png", | |
| 33 | type: 'error' | |
| 34 | }); | |
| 35 | } | |
| 36 | } | |
| 37 | }); |