如何使用Jquery动态加载Div中的内容? (代码给出)

时间:2018-03-11 00:02:24

标签: javascript php jquery html

我希望在我的内容网站上覆盖一下。因此,如果有人点击链接,则会将文章加载到覆盖覆盖区Div

除输出无法正常工作外,一切正常。

<script language="javascript">

    $( ".iddd" ).click(function() {
    var aid = $(this).prop('id');
    $('#overlaycontent').load('http://www.example.com/overlay.php', { id: aid });

    });

测试PHP脚本:

<?php 

include ("config.php");
$ID = $_POST['id'];

echo $ID;

?>

这就是我的链接的放置方式:

<a class="iddd" href="#overlay" id="6337cab172">

应该将id加载到脚本中,以便我可以访问我的文章,但我猜Jquery无法正常工作。

我看了这个overlay with dynamic php content the right way?

但仍然没有正确发布ID!     

1 个答案:

答案 0 :(得分:0)

不确定config.php中有什么内容,如果遗漏可能会导致您的问题,但要包含文件,则不要使用括号,但只能使用引号,因此,而不是

include ("config.php");

只是

include "config.php";