How to use magnific popup in a gallery with form submit

How to use magnific popup in a gallery with form submit

Hello. I have a code that allows to display folders content dynamically, like an image gallery with deep levels.
I asked a question related to this code in https://forum.jquery.com/topic/help-with-a-code-to-get-file-location-dynamically
I urgently need to ask another question related to magnific popup.
In this code I make a request to ajax after sending form data to open a directory folder dynamically with glob function. I need to display folder content like a modal pop-up gallery using magnific-pop up.
Since this plugin needs to be executed after $(document).ready, e.g.

  1.                 $(document).ready(function(){
                        $('.popup-modal').magnificPopup({
                            callbacks : {
                                open : function(){
                                    $.ajax({
                                    });
                                }
                            }
                        });     

how can I send form data with $('form').submit to open glob function?