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 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀