How to enable FancyBox only after receiving the server's response?

On the server in the absence of data giving the header 403 and the text of the error, it is necessary in the case of this error fail to open the FancyBox, and at the moment it (works only partially). The fact that there is a dark background, ie, fancybox starts executing and waits for server response, if 200 is all right, but in the case 403, there is a dark background. How to be?

here is the code:
(function($) {
 $(document).ready(function () {
 var $btn = $('[data-router="btn-fancyBox"]');

 "href": this.href
 "type": "ajax",
 "ajax": {
 "method": "POST",
 "data": $,
 statusCode: {
 200: function() {
 403: function(e) {
 return $('.message')
 .message('start', e);
 maxWidth : 700,
 maxHeight : 500,
 fitToView : false,
 width : "100%",
 height : "100%",
 autoSize : false,
 closeClick : false,
 openEffect : 'none',
 closeEffect : 'none'
July 12th 19 at 16:48
1 answer
July 12th 19 at 16:50
I would try to first load the data a separate function to initialize the fancybox only in case of successful server response.
Yeah ))) I about it had not thought of that, already done =) - Bonita commented on July 12th 19 at 16:53

Find more questions by tags jQuery