I want to catch a fancybox error (The requested content cannot be loaded.
Please try again later.) and try another fancybox type.
Like this. First time It tries ajax and if that returns error, try iframe.
jQuery('.lightwindow').click(function() {
var element = this;
jQuery(element).fancybox({
error: function() {
// If this didn't work, try iframe
jQuery(element).fancybox({
type: 'iframe',
autoSize: true
});
}
});
return false;
});
But that doesn’t work. It will just show the error from the first fancybox.
The option
errordoes not exists, you can set thetypeto'ajax'and edit the ajax settings like thisajax : { error : function(){ ...change fancybox and load... } }then you have:But it is probably better to check before the request is made whether to use ajax or an iframe