-
-
Save ashchristopher/1142807 to your computer and use it in GitHub Desktop.
pop-up any 500s in an iframe using jQuery. Especially useful for Django errors.
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
$(document).bind('ajaxError', function(e, jqXHR){ | |
if (jqXHR.status == 500){ | |
var erframe = document.createElement('iframe'); | |
$('body').append(erframe); | |
$(erframe).css({ | |
'position': 'absolute', | |
'top': '5%', 'left': '50%', | |
'width': '90%', 'height': '90%', | |
'marginLeft': '-45%', | |
'z-index' : '9999999' | |
}).attr('id', 'errorframe'); | |
var doc = erframe.document; | |
if (erframe.contentDocument)// for moz | |
doc = erframe.contentDocument; | |
doc.open(); | |
doc.writeln(jqXHR.responseText); | |
doc.close(); | |
var close = $('<a href="#" id="errorclose">X</a>'); | |
$('body').append(close); | |
close.css({ | |
'position': 'absolute', | |
'top': '0', 'right': '0', | |
'padding': '5px' | |
}).click(function(e){ | |
$('#errorframe').remove(); | |
close.remove(); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment