Re-enabled global ajax error messages.
This commit is contained in:
parent
62b46e0052
commit
f921df1045
1 changed files with 6 additions and 3 deletions
|
@ -2,11 +2,11 @@ class App.Com
|
||||||
_instance = undefined # Must be declared here to force the closure on the class
|
_instance = undefined # Must be declared here to force the closure on the class
|
||||||
@ajax: (args) -> # Must be a static method
|
@ajax: (args) -> # Must be a static method
|
||||||
if _instance == undefined
|
if _instance == undefined
|
||||||
_instance ?= new _Singleton
|
_instance ?= new _ajaxSingleton
|
||||||
_instance.ajax(args)
|
_instance.ajax(args)
|
||||||
|
|
||||||
# The actual Singleton class
|
# The actual Singleton class
|
||||||
class _Singleton
|
class _ajaxSingleton
|
||||||
defaults:
|
defaults:
|
||||||
contentType: 'application/json'
|
contentType: 'application/json'
|
||||||
dataType: 'json'
|
dataType: 'json'
|
||||||
|
@ -33,7 +33,7 @@ class _Singleton
|
||||||
)
|
)
|
||||||
|
|
||||||
# show error messages
|
# show error messages
|
||||||
$('body').bind( 'ajaxError', ( e, jqxhr, settings, exception ) ->
|
$(document).bind( 'ajaxError', ( e, jqxhr, settings, exception ) ->
|
||||||
status = jqxhr.status
|
status = jqxhr.status
|
||||||
detail = jqxhr.responseText
|
detail = jqxhr.responseText
|
||||||
if !status && !detail
|
if !status && !detail
|
||||||
|
@ -45,6 +45,9 @@ class _Singleton
|
||||||
# do not show any error message on wrong login
|
# do not show any error message on wrong login
|
||||||
return if status is 422
|
return if status is 422
|
||||||
|
|
||||||
|
# do not show any error message with code 200
|
||||||
|
return if status is 200
|
||||||
|
|
||||||
# show human readable message
|
# show human readable message
|
||||||
if status is 401
|
if status is 401
|
||||||
status = 'Access denied.'
|
status = 'Access denied.'
|
||||||
|
|
Loading…
Reference in a new issue