douyinzha5820 2014-10-13 07:08
浏览 63
已采纳

JavaScript:在div中加载包含PHP函数的文件

I have this situation.

file.html

.......
<div id="mydiv">
</div>
.......

myjsfile.js

............
$("#mydiv").load("myphpfile.html");
............

myphpfile.html

............
<?php
    include("myfile.php");
?>
............

The content of myphpfile.php is not viewed. How can I show the content of myphpfile.php in selected div?

Thanks.

  • 写回答

2条回答 默认 最新

  • duanmao1919 2014-10-13 07:16
    关注

    You can use php also in load funtion.

    $(document).ready(function(e) {
             $("#mydiv").load("myfile.php");
    });
    

    Above code will load after page loaded

    include("myfile.php");
    

    include function will run before loading html and javascript codes..

    Use this script file for library jquery-1.9.1.js

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 用PLC设计纸袋糊底机送料系统
  • ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
  • ¥15 用C语言输入方程怎么
  • ¥15 网站显示不安全连接问题
  • ¥15 github训练的模型参数无法下载
  • ¥15 51单片机显示器问题
  • ¥20 关于#qt#的问题:Qt代码的移植问题
  • ¥50 求图像处理的matlab方案
  • ¥50 winform中使用edge的Kiosk模式
  • ¥15 关于#python#的问题:功能监听网页