jQuery/JS:fancybox 从 ajax 调用加载

发布于 2024-10-08 02:52:33 字数 568 浏览 0 评论 0原文

现在,当你制作一个 fancybox 时,你初始化一个链接并进行一些设置:

    $("a#a_sendMail").fancybox({
'titleShow'     : false,
'width':    400,
'height':   120,
'autoDimensions': false,
'overlayOpacity': 0.6
    }); 

然后你用 id a_sendMail 进行链接,然后 href="#sendMail" 然后你为其制作 div:

<div style="display: none">
<div id="newMail">
This is inside the fancybox :)
</div>
</div>

现在,我想改为在保存内容的同一文件中创建一个 div 时,我想调用 newMail.php,其输出应显示为一个框。因此,当您单击链接(为了打开该框)时,它会发出 ajax 请求并返回/响应其中将显示的内容。

我怎样才能以最聪明、最简单的方式做到这一点?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

川水往事 2024-10-15 02:52:33

您可以将 href 选项添加到 fancybox,如下所示:

$("a#a_sendMail").fancybox({
    titleShow     : false,
    width:    400,
    height:   120,
    autoDimensions: false,
    overlayOpacity: 0.6,
    href: 'newMail.php' // <----- this is the option 
}); 

您可以在此处查看所有选项: http://fancybox.net/ API

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文