Created
August 21, 2009 19:21
-
-
Save house9/172345 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function defaultAjaxErrorHandler(result, isAjaxError) { | |
// do stuff, hide spinner etc... | |
var defaultAjaxError = "Your friendly error message"; | |
var errorToken = "Error:"; | |
if(!isUndefinedOrNull(result) && !isUndefinedOrNull(result.responseText)) { | |
if(result.responseText.startsWith(errorToken)) { | |
// localhost | |
var x = (result.responseText.length > 350) ? 350 : result.responseText.length; | |
alert(result.responseText.substring(0, x) + "...\n\n - Check firebug console for more info.\n - This message for localhost only."); | |
} | |
else { | |
// production error | |
alert(defaultAjaxError); | |
} | |
} | |
else { | |
// production error | |
alert(defaultAjaxError); | |
} | |
} | |
function isUndefinedOrNull(x) { | |
var u; // undefined var | |
if(x === u) { // similar to [typeof x == "undefined"] | |
return true; | |
} | |
// else | |
return x === null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment