I would like to refresh the image after selecting another item from menu:
<html>
<head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script>
$(function() {
$( "#selectable" ).selectable({
stop: function() {
$( ".ui-selected", this ).each(function() {
// Works on FF; doesn't work on Chrome and IE
d = new Date();
$("#chart_image").prop("src", this.id + "?" + d.getTime());
});
}
});
});
$(function() {
// Selects the first <li> element
$( "#selectable" ).selectable().children().first().addClass('ui-selected');
});
</script>
</head>
<body>
<?php
header('Cache-Control: no-cache, no-store, must-revalidate');
header('Pragma: no-cache');
header('Expires: 0');
$dirname = "charts/";
$images = glob($dirname."*.svg");
echo '<ol id="selectable">';
foreach($images as $image) {
echo '<li class="ui-widget-content" id="'.$image.'">'.basename($image, ".svg").'</li>';
}
echo '</ol>';
echo '<figure><embed id="chart_image" type="image/svg+xml" src="'.$images[0].'"></embed></figure>';
?>
</body>
</html>
The above code works well on FF. However, on Chrome and IE nothing happens after selecting different menu items. I have tried the trick with appending current timestamp to the end of the file. I also tried with the cache headers - no results.
Thanks!