dimsemenov / Magnific-Popup

Light and responsive lightbox script with focus on performance.
http://dimsemenov.com/plugins/magnific-popup/
MIT License
11.38k stars 3.49k forks source link

Load Php Form #1096

Open senrabdet opened 5 years ago

senrabdet commented 5 years ago

Hi All: I'm not sure if what I'm asking is possible (or advisable), but I'm hoping to accomplish the following (use case) that gets php to work inside of Magnific popups given php is server side:

I've been trying to construct this looking at various posts, and (am a newbie) my attempts either don't work or they open a new page which could be what I have to do, but I'd prefer a popup not a new page.

My code (am trying the simplest approach I can think of that only is aimed at getting php to work, does not include the mysql statements yet) is:

1) Code in table cell (wpdatatables): a class="popup" href"#" alt="" data-content-id="#thepop6">Pop</a> <html> <head> <script type="text/javascript"> $('a.your-link').on('click',function(e){ e.preventDefault(); $.ajax({ type: "POST", // or POST url: 'myform.php', data: { get_request_id : $(this).data('id'), // assign a data-id to the link },
success: function(data){ $.magnificPopup.open({ type: 'inline', closeOnContentClick: false, items: { src: myform.php } }) } }); });

</script> </head> <body> <form action="http://localhost/myform.php" method="post"> <div id="thepop6" class="white-popup mfp-hide"> <a href="http://localhost/myform.php" class="simple-ajax-iframe">form</a>

</form> </body> </html>

2) php file (myform.php) <html> <head> <title>PHP Test </head> <body> <?php`` echo '<p>Hello World</p>'; ?> </body> </html>

I've seen examples with "callback" but am stuck. Help! Thx