AJAX UPDATE + PHP + IE =失败?

时间:2010-02-06 12:39:01

标签: php ajax internet-explorer

从这个帖子开始:Another IE jQuery AJAX/post problem(请阅读线程以了解这一点)

现在我已经为上面的线程提供了一个解决方案..但是,ok.php(它使用AJAX脚本每10秒更新一次的站点)如果响应包含HTML代码,则不会在IE中显示。我的意思是,如果我有: (ok.php)

<?php
ob_start();
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header('Content-type: text/html; charset=utf-8');
ob_flush();
echo "hello";
?>

它可以在IE和FF中工作......但是,如果我有: (在ok.php中)

<?php
ob_start();
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header('Content-type: text/html; charset=utf-8');
ob_flush();
include "../tilslut.php";
$sql = "SELECT id FROM member_comments WHERE fID = '19'";
 $query = mysql_query($sql);
 $number = mysql_num_rows($query);
 echo("There is <b>".$number."</b> comments!<br><br>");
?>

它只能在firefox中显示/显示,而不是在IE中显示。

帮帮我吧! :(先谢谢你。

2 个答案:

答案 0 :(得分:1)

也许路径尝试使用include(dirname(__ FILE __)。'/ .. / tilslut.php')。这应该会给你带来错误,但最好这样做。尝试将ajax_update放在这样的脚本中:

<script>
jQuery(document).ready(function(){ajax_update();});
</script>

而不是onload

答案 1 :(得分:0)

首先获取IE的Fiddler2插件,以便检查您的HTTP流量。

通过它,您将能够验证您是sending正确的请求和returning正确的回复。

同时验证使用view-source或IE开发人员工具,你没有得到内容回来确定,但不知何故IE没有显示它(例如它在源中,但不可见)

例如,如果您尝试将返回的HTML设置为表或选择列表的内容...这将在IE中失败。