【问题标题】:Reload div with jQuery (file not found)使用 jQuery 重新加载 div(未找到文件)
【发布时间】:2012-09-02 16:24:00
【问题描述】:

我有这个脚本:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script> 
<script  type="text/javascript"> 
var updateGallery = setInterval(function() {
$('#gmap2').fadeOut('fast').load('map.php').fadeIn('fast');}, 10000);
</script>

需要加载文件(map.php)。

我在 index.php 页面中有这行代码;

<div id="gmap2"> <?php include 'map.php'; ?></div>

在 firefox 错误控制台中,我得到 Network error 404 File not found (http://domain.com/map.php) 即使我将完整的 url 路径放入 map.php 文件,我也会遇到同样的错误。

感谢帮助

【问题讨论】:

  • 您的问题不清楚。 1)你的javascript在哪里? 2)你为什么提到一个php文件的服务器端包含? 3)如果你有一个404错误,这是你的JS加载文件的明显问题,你能给我们关于这个错误的其他信息吗?

标签: jquery html reload


【解决方案1】:

这里没有足够的信息给你答案,但这里是你首先要看的地方:

您的 http 服务器日志(和 HTTP 错误日志)应该显示您的脚本试图获取的 URL(以及文件)。注意相对 URL 是否根据包含它们的资源(文件)进行解析。

根据您的托管服务和/或 Web 服务器,这些可能位于您使用 ftp 或 ssh 登录的子目录中;在我的系统上,它们位于 /var/log/httpd/error_log 和 /var/log/httpd/access_log (如果服务器繁忙,它们可能是大文件!)。

在进行 AJAX 开发时,运行“tail -f /var/log/httpd/error_log”会有所帮助。

【讨论】:

  • 感谢您的快速回答,我在 error_log 中找到了这个:PHP 警告:include() [function.include]: Failed opening 'map .php' 用于包含(include_path='.:/usr/lib/php:/usr/local/lib/php')在第 140 行的 /home/simple/public_html/wp-content/themes/960bc/index.php
  • map.php在服务器的什么目录下?
  • domain.net/wp-content/themes/960bc,同主题和index.php。是主题根目录
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-12-27
  • 2013-06-03
  • 2014-09-06
  • 1970-01-01
  • 2021-05-31
  • 2017-03-15
相关资源
最近更新 更多