从 DIV 加载 PHP 脚本


Loading a PHP script from a DIV

我可以得到一些帮助来从DIV调用加载PHP文件吗?

这是我的代码:

<html>
<head>
</head>
<body>
    <script class="code" type="text/javascript">
        $("#LoadPHP").load("fb_marketing.php");
    </script>
    <div id="LoadPHP">Load PHP Here</div>
</body>
</html>

如果你不知道我想做什么,我会解释一下。基本上,我想在网页上引用 DIV 时加载"fb_marketing.php"文件。

上面的代码不起作用。我可以得到一些帮助来让它工作吗?

提前致谢

我相信

你缺少你的jQuery库。为了调用作为 jQuery 库一部分的 load 函数,您需要将该库包含在head中。

此外,我会等到首先加载整个 DOM 时,将代码包装在 $.ready(function() { //code here }); 方法中。

这是你要找的吗?

<div id="LoadPHP">
<?php
echo "this is where your php would go";
?>
</div>

<div id="LoadPHP">
<?php
include 'testPHP.php';
?>    
</div>