问题
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