Created
April 11, 2011 19:06
-
-
Save defrex/914083 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 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%' | |
}).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
FYI, you can collapse those css declarations by just passing an object rather than chaining calls. Example: