douyue1998 2012-04-27 03:38
浏览 38

使用Jquery FancyBox包含DOM

I am trying to use the Fancy Box 2 plugin (

All is well except I cannot figure out how to include a DOM element properly.

I am calling this after a form submit that is returning information via ajaxform and validation. documentation says to use the following for dom.

//DOM element:

$.fancybox( $("#inline"), {
    title : 'Custom Title'

Now if i create an id on the page in a div it doesn't pull it. Also the div shows.

I tried using the other method (custom object)

    href: 'example.jpg',
    title : 'Custom Title'

and it does not seem to work with php files. I am trying to populate the lightbox with information from a php file but i get error loading content.

  • 写回答

3条回答 默认 最新

  • dsz90288 2012-04-27 03:57

    You should probably use ajax() in here.

    As I look into the FancyBox plugin, it does support ajax.

        ajax: {
            type: "POST",
            data: 'mydata=test'


    <li><a id="various3" href="/data/login.php">Ajax - passing custom data</a></li>

    All of these where based on its demo's source code. Demo page &


    I did a quick test using fancyBox version 2, pertaining your question.

    I achieve to pull the ajax contents:

    $(document).ready(function() {
            title: 'Custom Title'


    <a class="fancybox fancybox.ajax" href="ajax.txt">Show content</a>
    <div id="content">

    I've noticed that the important part in here is naming your class to class="fancybox fancybox.ajax".

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥20 keepalive配置业务服务双机单活的方法。业务服务一定是要双机单活的方式
  • ¥50 关于多次提交POST数据后,无法获取到POST数据参数的问题
  • ¥15 win10,这种情况怎么办
  • ¥15 如何在配置使用Prettier的VSCode中通过Better Align插件来对齐等式?(相关搜索:格式化)
  • ¥100 在连接内网VPN时,如何同时保持互联网连接
  • ¥15 MATLAB中使用parfor,矩阵Removal的有效索引在parfor循环中受限制
  • ¥20 Win 10 LTSC 1809版本如何无损提升到20H1版本
  • ¥50 win10 LTSC 虚拟键盘不弹出
  • ¥30 微信小程序请求失败,网页能正常带锁访问
  • ¥15 Matlab求解微分方程,如何用fish2d进行预优?