dongsong8932 2014-03-19 09:43
浏览 52
已采纳

Thickbox不显示通过jQuery.get()获取的文件的内容

I am trying to open a php file (containing HTML markup) within Thickbox in WordPress.

So far, I have managed to get the Thickbox open up. The URL to the php file is also correct but it's content does not load up in the thick box. Here is my code:

Here is my Code :

$('.add').click(function() {
    $('html').addClass('image_spe');
    num = $(this).attr('data-num');
    formfield = $('.id_img[data-num="'+num+'"]').attr('name');
    var id=$("#post_ID").val();
    jQuery.get(dialog_url, function(){ /* here, dialog_url is the URL to the PHP file*/
    var f = jQuery(window).width();
        b = jQuery(window).height();
        f = 920 < f ? 920 : f;
        f -= 80;
        l = f/2;
        b -= 84;
        tb_show('Add', "#TB_inline?post_id="+id+"&width=" + f + "&height=" + b + "&inlineId=my-dialog");
        jQuery("#TB_window").css({'width':920, 'margin-left':-l});
    });

    return false;
});

The PHP code is here :

<?php 
?>
  <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      </head>
      <body>
          <div id="my-dialog">
              <p>TESTING... YOU SHOULD BE ABLE TO SEE THIS IN THICKBOX</p>
          </div>
      </body>
  </html>
<?php ?>

The thickbox opens without any issues and the URL to the file is correct. But the content is not displayed.

How can i do this ?

  • 写回答

2条回答 默认 最新

  • dongshang1979 2014-03-19 14:52
    关注

    jQuery.get() might need a small modification.

    Change this...

    jQuery.get(dialog_url, function(){...}
    

    ...to this

    jQuery.get(dialog_url, function(data){
        jQuery('body').append(data);
        ...
    }
    

    Hopefully it should work!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python