【发布时间】:2015-06-11 04:48:59
【问题描述】:
我想显示一个弹出窗口,其中的内容来自另一个文件。 现在,当弹出窗口的内容出现在同一页面上时,我正在使用此代码显示弹出窗口。
jQuery(".item").click(function(e) {
var currentID = jQuery(this).attr("id");
jQuery.ajax({
method: "POST",
url: "some.php",
data: {
name: "John",
location: "Boston"
}
})
.done(function(msg) {
jQuery(".popup-overlay").html(msg);
jQuery("." + currentID).fadeIn(300, function() {
jQuery(this).focus();
});
jQuery(".popup-overlay").show();
});
});
我能不能把要在弹出窗口中显示的内容放在其他文件中,然后在上面的代码中传递文件的路径
这将是 ajax.php 中的代码
<?php include("wp-load.php"); ?>
<div class="popup-overlay">
<?php
$args = array(
'post_type' => 'portfolio',
);
$loop=new WP_Query;
$count=1;
if($loop->have_posts()):whiile(have_posts()) :the_post();
?>
<div class="popup-box <?php echo $count; ?> ">
<div class="inner-box">
</div>
</div>
<?php
$count;
endwhile;
endif;
?>
</div>
现在它正在获取 ajax.php 中的所有 div。
它应该只显示具有 class="currentID" 的 div
【问题讨论】: