【发布时间】:2014-07-29 11:19:39
【问题描述】:
我想使用 jquery ajax 通过需要不同的 php 文件来更改我的 div 元素的内容。
这里是 ajax 代码:
$.ajax({
url:"/project/Functions/project_functions.php",
type:"POST",
data:{
functions:num
},
success:function(result){
$("#right_bot").html(result);
}
});
project_functions.php 类似于:
$result = '<?php require "Panels/Project/Main/main.php" ?>';
echo $result;
我可以看到正在输出的值,但是 html 注释掉了 php 部分
<!--?php require "Panels/Project/Main/main.php" ?-->
它只是从 php.ini 中提取出来。有没有办法将不同的 php 文件加载到我的 div 中?
在main.php文件中,有php代码,html代码,还有一些style标签。我可以使用 ajax 将所有这些加载到 div 元素中吗?还是我必须回显我所有的 html 代码?
【问题讨论】:
-
在网络检查器中检查“网络”选项卡时,当您请求
/project/Functions/project_functions.php时会返回什么? -
我使用 dendule 来查看生成的代码。在 #right_bot div 中,它注释掉 /project/Functions/project_functions.php?
-
放弃变量赋值和回显,只需
<?php require "Panels/Project/Main/main.php" ?>就是这样 -
还是把代码注释掉
-
等等,你真的想显示原始的php代码,例如在你的div中显示php标签等,或者你想显示代码的输出,例如html
标签: javascript php jquery html ajax