My javascript code appears to work as it's supposed to. However, when I 'view source' in Chrome, it disagrees with the javascript that is actually executed.
Here is my code:
<?php
$_SESSION['new'] = "blue";
if (!isset($_SESSION['old'])) { $_SESSION['old'] = "blue"; }
echo '<script type="text/javascript">
$(document).ready(function() {
changeCol("'.$_SESSION["old"].'","'.$_SESSION["new"].'");
});
</script>';
$_SESSION['old'] = "blue";
?>
$_SESSION['old']="green"
from the previous page. The code is supposed to call changeCol("green","blue")
, and then set $_SESSION['old']="blue"
.
In fact, both of these things happen, so my code works as it's designed, but if I view source, it says changeCol("blue","blue")
. This is strange, because if in changeCol() I write the passed variables to console.log
, I get green, blue
.
So if it's calling changeCol(green,blue)
why does it say changeCol(blue,blue)
when I view source?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…