铬+;返回邮政+;重载=ajax错误
问题:google chrome出现ajax错误 index.html---POST--->page1.php---link--->page2.html铬+;返回邮政+;重载=ajax错误,ajax,google-chrome,post,reload,back,Ajax,Google Chrome,Post,Reload,Back,问题:google chrome出现ajax错误 index.html---POST--->page1.php---link--->page2.html “index.html”包含一个发布到“page1.php”的 “page1.php”包含指向“page2.html”的链接 “page1.php”包含对“ajax.php”的ajax调用 如何使问题出现 访问“index.html” 发布到“page1.php” 点击“page2.html”链接 使用后退按钮返回到“page1.php” 用F
<html>
<head>
</head>
<body>
index
<form method="post" action="page1.php">
<input type="submit">
</form>
</body>
</html>
指数
page1.php:
<html>
<head>
<script src="jquery-1.10.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
function call_ajax()
{
$.ajax
(
{
type: "POST",
url: "ajax.php",
success: function( response )
{
console.log( response );
},
error: function (xhr, ajaxOptions, thrownError)
{
console.log( '%o', xhr );
console.log( '%o', xhr.responseText );
console.log( '%o', thrownError );
}
}
);
}
$( document ).ready(function() {
call_ajax();
});
</script>
</head>
<body>
page 1
<a href="page2.html">page2</a>
</body>
</html>
函数调用_ajax()
{
$.ajax
(
{
类型:“POST”,
url:“ajax.php”,
成功:功能(响应)
{
控制台日志(响应);
},
错误:函数(xhr、ajaxOptions、thrownError)
{
console.log(“%o”,xhr);
console.log(“%o”,xhr.responseText);
console.log(“%o”,thrownError);
}
}
);
}
$(文档).ready(函数(){
调用_ajax();
});
第1页
第2.html页:
<html>
<head>
</head>
<body>
page 2
<a href="javascript:history.back()">back</a>
</body>
</html>
第2页
ajax.php:
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('error_reporting', E_ALL);
header('Cache-Control: no-cache, must-revalidate');
header('Content-type: application/json');
$r = array( 'message' => 'one two one two, this is a test' );
echo json_encode( $r );
?>
可能是服务器/浏览器的配置有问题吗 我试图通过使用PHP通过fastcgi和运行Chromium版本30.0.1553.0(209444)在本地安装的lighttpd中创建与上述代码完全相同的文件来确认您的问题,但无法重现您的问题 查看控制台时,无论我是从index.html访问page1.php还是使用“back”链接从page2.html访问page1.php并使用F5刷新,日志始终显示正确的输出
Object {message: "one two one two, this is a test"}
事实上,我已经尝试过谷歌chrome的另一个版本,我无法重现这个问题。此版本中出现问题:25.0.1364.152谢谢您的回答,谜团已解决。