I am developing with xhtml, LAMP and jQuery 2.0.2 on Debian 7.0.0.
I am using the following php-generated element
echo "<img id=\"displayImageID\" src=\"" . $DisplayFileName . "\" alt=\"Background\" style=\"margin:10px 0px 10px 5px\"/>";
I am hoping to change it to a different color look up table when the used clicks on a radio button. In order to do this, I use the following code
jQuery.ajax({
type: "POST",
url: "DisplayParameters.php",
data: { LUT:lut }
}).done(function( result ) {
$("#msg").html( " Ajax called" );
});
with the following code in DisplayParameters.php
$LUT=$_POST['LUT'];
$Executable="Executables/changeLUT";
$DisplayImageName="images/display.png";
$Str=$Executable . " -t " . $LUT" . " -o " . $DisplayImageName;
$output=exec($Str, $dummy, $returnValue);
echo "<script language=\"JavaScript\">";
echo "d = new Date();";
echo "jQuery('#displayImageID').attr('src', '" . $DisplayImageName . "?'+d.getTime());";
echo "</script>";
}
to update the image and to reload it into the image element but nothing happens until I refresh the whole page with the Firefox "Reload current page".
I had thought that maybe, due to the asynchronous nature of Ajax, the image is getting loaded before it is replaced by a new image with the same name but different color LUT. However, if this were the case, I would expect the new LUT image to eventually be loaded if I keep clicking on radio buttons after the image that is saved to the disk is changed. This is not the case. I do not get a new image until I reload the page.