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条)

报告相同问题?

悬赏问题

  • ¥20 MIT控制器能控制不稳定系统吗
  • ¥15 公司代码X对业务伙伴X无效,处理方法?
  • ¥15 微信内链接跳转到浏览器打开怎么实现
  • ¥15 三角波可以直接加施密特电路整形到矩形波吗实物
  • ¥15 html,php,在使用html请求php文件时发生了错误,无法请求到php文件读取数据库并用javascript进行数据显示,刷新
  • ¥15 touchsocket udp组播
  • ¥20 MAC怎么安装Silverlight 插件?以及安装了怎么启用
  • ¥15 VS2012中查询语句无法填入解析,数值传不进去
  • ¥15 gis系统开发出现命名空间“ESRI.ArcGIS”中不存在类型或命名空间名“Analyst3D”报错
  • ¥15 怎么让ai定时给我发信息 c#或者python