jQuery/JS: fancybox load from ajax call
Right now when you make a fancybox you initialize a link and give some settings:
$("a#a_sendMail").fancybox({
'titleShow' : false,
'width': 400,
'height': 120,
'autoDimensions': false,
'overlayOpacity': 0.6
});
and then you do the link with id a_sendMail, and then href="#sendMail" and then you make the div for it:
<div style="display: none">
<div id="newMail">
This is inside the fancybox :)
</div>
</div>
Now, I would like to inst开发者_JS百科ead of making a div in the same file that holds the content, I would like to call newMail.php, and the output of this should be shown as a box. So when you click the link(in order to open the box), it makes a ajax request and return/response with the content that are going to show inside it.
How can I do this the most smartest and simple way?
You can add the href option to fancybox, like this:
$("a#a_sendMail").fancybox({
titleShow : false,
width: 400,
height: 120,
autoDimensions: false,
overlayOpacity: 0.6,
href: 'newMail.php' // <----- this is the option
});
You can view all the options right here: http://fancybox.net/api
精彩评论