【问题标题】:Not able to run my first program after installing WAMP [duplicate]安装 WAMP 后无法运行我的第一个程序 [重复]
【发布时间】:2013-10-18 04:51:19
【问题描述】:

我安装了 WAMP。我通过 localhost\index.php 对其进行了测试,工作正常。然后我在名为 firstproject 的 www 文件夹下创建了我的第一个项目。我把 index.html 和 xyz.php 放在里面。我的 xyz.php 内容是

<?php
  echo "My first PHP script!";
?>

我的 index.html 内容是:

<html lang="en">
  <head>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script type="text/javascript">
      $(document).ready(function(){
        var auto_refresh = setInterval(function (){
          //alert("abc");
          $('#mydiv').load('xyz.php').fadeIn("slow");
        }, 1000); 
      });
    </script>
  </head>
  <body>
    <div id="mydiv"> </div>
  </body>
</html>

当我运行 index.html 时,浏览器是空白的。当我尝试像 localhost/firstproject/xyz.php 一样直接访问 xyz.php 时,它可以工作

昨天我也问过类似的问题,

SetInterval function is not working with PHP File

每个人都说它适用于他们的系统。那为什么它不能在我的系统上运行。有什么我需要做的配置吗?请建议。我无法运行这个简单的项目。

【问题讨论】:

  • 为什么localhost后面有冒号:?调用index.html 时使用的网址是什么?我们还阅读了virtual hosts for apache2。
  • 假设您使用的是 Windows,请考虑使用 xampp - 易于配置...您需要配置文档根目录
  • @Ryan - 我在 Windows 7 上。控制台 - 我已经用最新的谷歌 CDN 更新了 jQuery。 gwillie - 删除冒号。这是一个打字错误。
  • 你打电话给http://localhost/firstproject/index.html 吗?你确定你的 load() 函数中 xyz.php 的路径是正确的吗?在 Firefox 或 Chrome 的 Dev COnsole (F12) 中打开 FireBug,看看你得到了什么错误。几点注意事项:1)不要转发问题; 2)始终在您的页面中放置一个文档类型
  • @all - 用 index.php 重命名 index.html 并通过 localhost/firstproject/index.php 调用它正在工作

标签: php jquery ajax apache wamp


【解决方案1】:

您的代码非常好。检查您的浏览器中是否启用了 javascript。如果不是,请启用它并重新启动浏览器。

【讨论】:

  • 用 index.php 重命名 index.html 并通过 localhost/firstproject/index.php 调用它是有效的
  • 好吧。它使用你的方式在我的 XAMPP 中工作。
【解决方案2】:

我将 index.html 重命名为 index.php 并由 localhost/firstproject/index.php 调用。成功了

【讨论】:

    猜你喜欢
    • 2019-03-30
    • 2014-06-13
    • 2021-07-21
    • 1970-01-01
    • 1970-01-01
    • 2016-04-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多