【问题标题】:Loading php content in div only仅在 div 中加载 php 内容
【发布时间】:2013-12-24 06:40:04
【问题描述】:

我已经在 stackoverflow 上查看了这个 Link,但我似乎无法在这里加载 div 是我的代码

<div id="leftmenu" style="font-size:20px;position:absolute;top:12%;bottom:0;right:0;left:2%;">
                <a href="#" id="details"> Form </a>
</div>

<div id="content" style="font-size:20px;position:absolute;top:12%;bottom:0;right:10%;left:12%;">
</div>

<script>
          $(document).ready(function(){
            $("#details").click(function(){
                $("#content").load('student_details.php');
            });
          });
</script>

编辑:对加载部分进行了更改,但仍然不适合我

编辑2:

<!DOCTYPE html>
<html>
    <head>
       <title> test </title> 
       <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
       </script>
    </head>
    <body>
        <div id="leftmenu" style="font-size:20px;position:absolute;top:12%;bottom:0;right:0;left:2%;width:100px;height:100px;">
                <a href="#" id="details"> Form </a>
        </div>

        <div id="content" style="font-size:20px;position:absolute;top:12%;bottom:0;right:10%;left:12%;">
        </div>
        <script>
          $(document).ready(function(){
            $("#details").click(function(){
                $("#content").load('load.html');
            });
          });
        </script>
    </body>
</html>

以下代码也无法运行 D 中存在的 load.html 文件:驱动器我在 div 中做错了吗?或者可能是脚本标签?

load.html 的内容是“this works”

【问题讨论】:

  • $("#content").load('student_details.php');
  • 检查给定的url是否有效!
  • 嗨,我试过没有运气
  • 尝试使用完整的网址。 $("#content").load('site.com/something/student_details.php');
  • 您的&lt;div&gt; 在屏幕上是否有任何尺寸使其能够被点击?如果 div 的宽度/高度是0px,那么点击它会有点困难。使用您的浏览器开发者工具来验证这一点。

标签: php jquery css html


【解决方案1】:

url 必须作为包含在''"" 中的字符串传递

$("#content").load('student_details.php');

【讨论】:

    【解决方案2】:

    文件路径必须是字符串。所以而不是:

    $("#content").load(student_details.php);
    

    你会说:

    $("#content").load("student_details.php");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-31
      • 1970-01-01
      • 2013-09-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多