Lightbox: Fixed incorrect closing of AJAX popups.

Fixes #5594. Fixes #5391.

Issue caused by doctype, html element and comments in the AJAXed content. Seems to trip up Magnific Popup by making mfp.content[0] into a text object (which breaks the $.contains checks).