我正在尝试在WordPress的Thickbox中打开一个php文件(包含HTML标记)。
到目前为止,我已经成功打开了Thickbox。 php文件的URL也是正确的,但它的内容不会在厚框中加载。这是我的代码:
这是我的代码:
$('.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;
});
PHP代码在这里:
<?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 ?>
厚箱打开没有任何问题,文件的URL是正确的。但内容未显示。
我该怎么做?
答案 0 :(得分:1)
从HTML周围删除<?php
和?>
。
此外,您没有对使用.get()
加载的数据执行任何操作。你应该阅读文档。
答案 1 :(得分:0)
jQuery.get()可能需要进行一些小修改。
改变这个......
jQuery.get(dialog_url, function(){...}
...到此
jQuery.get(dialog_url, function(data){
jQuery('body').append(data);
...
}
希望它能够奏效!