简体   繁体   中英

Message in Fancybox popup generated by PHP

I would like to achieve rather simple thing I guess but I'm unable to figure out how to do it. I need to have a message that pops out in a jQuery Fancybox window after being generated by PHP.

The code that would show the message could be that simple:

if(something){
    echo 'message sent!';
}

In this case I would want the "Message sent!" text to appear in Fancybox window.

Any help will be appreciated

Assuming that you are using fancybox v2.x and that you have properly initialized jQuery and fancybox files in your php document, I would do:

<?php        
    if(something) { 
      $message = "message sent!";
?>

<script>
    $(document).ready(function() {
        $.fancybox("<?php echo $message; ?>",{
            minWidth: 'auto',
            minHeight: 'auto'
        }); // fancybox
    }); // ready
</script>

<?php 
    }; // close php if
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM