Message in Fancybox popup generated by PHP

给你一囗甜甜゛ 提交于 2019-12-25 08:59:59

问题


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


回答1:


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
?>


来源:https://stackoverflow.com/questions/8436952/message-in-fancybox-popup-generated-by-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!