jackmoore / colorbox

A light-weight, customizable lightbox plugin for jQuery
http://www.jacklmoore.com/colorbox/
MIT License
4.75k stars 1.14k forks source link

problems with colorbox gallery via form submit #810

Open ilustrador opened 7 years ago

ilustrador commented 7 years ago

I'm trying to make a gallery. In this gallery the user choose something (eg. a link, an input image) to open a certain gallery. Something like gallery of galleries. I use forms instead href. Thus a variable is sent via form submit to open some directory with php glob on another page. I need to display images through iframes inside colorbox. I've tried with this but I didn't get anything. page1.php `

        <input type="submit" value="author">
    </form>
<a id="link" style="display:none"></a>
<div id="msg" style="display:none;"></div>
<script>
    $("#link").colorbox({inline:true,href:"#msg"});
    $('#formID').submit(function () {const data = $(this).serialize();
        $.ajax({type: 'POST',url: 'page2.php',data: data,success (data) {        $('#msg').html(data);$('#link').click();}})
        return false;})
</script>    `

page2.php <?php $variable = $_POST['var']; $img_dir = $variable . "/"; foreach(glob($img_dir . '*.jpg') as $image) { echo '<img src="'.$image.'">'; } ?> Thanks in advance.