Theme:
Popup:
Error handling demo
When a JavaScript error happens because of server error/incorrect url (500, 404) the only way you would know the reason is by using something like firebug/chrome dev tools (by looking in the console for the execution of ajax requests).You can also assign a js function to the
awe.err
,
this way whenever an error will occur your custom function will be executed.
awe.err = function(o, xhr, textStatus, errorThrown) {
var msg = "unexpected error occured";
if (xhr) {
msg = xhr.responseText;
}
msg += "(you see this message because in Site.js awe.err is set to a function that shows this popup) ";
var btnHide = $('<button type="button"> hide </button>').click(function() {
$(this).parent().remove();
});
var c = $('<div/>').html(msg).append(btnHide);
//decide where to attach the inline popup
if (o.p && o.p.isOpen) { // if helper has popup and is open
o.p.d.prepend(c); // put msg inside popup div
} else if (o.f) {
o.f.html(c); // put msg inside control field
} else $('body').prepend(c);
};
clicking on this popup links will throw a server exception, click on them to see how it's handled