problem : ajax error with google chrome
index.html --- POST ---> page1.php --- link ---> page2.html
<form>
that posts to “page1.php”how to make the problem appear ?
why is... that thing ?
index.html :
<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>
page2.html :
<html>
<head>
</head>
<body>
page 2
<a href="javascript:history.back()">back</a>
</body>
</html>
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 );
?>
Might it be, that there is something wrong with the configuration of your server/browser?
I tried to confirm your problem by creating the files with exactly the same code as above in my local installation of lighttpd using PHP via fastcgi and running Chromium version 30.0.1553.0 (209444), but was unable to reproduce your issue.
When looking at the console, the log always shows the correct output whether I access page1.php from index.html or from page2.html using the "back" link and refreshing with F5.
Object {message: "one two one two, this is a test"}