嘗試了這一點http://jsfiddle.net/Bvpft/16/
測試Chrome和FireFox。它刷新並重新下載圖像,但不知道除此之外它應該做什麼。
HTML
<!DOCTYPE html>
<body>
<div id="graph" >
<object type="text/html" style="width:100%; height:100%; margin:1%;" data="">
</object>
</div>
</body>
的Javascript
$(document).ready(function() {
var graph = $('#graph'),
uri = 'https://api.cosm.com/v2/feeds/120687/datastreams/sensor_reading.png?',
params = {
width: 740,
height: 150,
colour: '#0055ff',
duration: '5minutes',
legend: 'Vibration measure 0 -> 1024 ',
title: 'Foosball Vibrations - 5 Minutes',
show_axis_labels: 'true',
detailed_grid: 'true',
scale: 'manual',
max: 75,
timezone: 'Mountain Time (US & Canada)'
};
var updateGraph = function() {
var data = uri + $.param(params);
graph.empty();
graph.append($('<object/>')
.prop({'type': 'text/html', data: data})
.css({'width': '100%', 'height': '100%'}))
};
updateGraph();
setInterval (updateGraph, 1000);
});
編輯 - 改變到圖像時,由非閃爍,不添加緩存(在IE10,鉻和Firefox測試):http://jsfiddle.net/JAYDb/4/
HTML
<div id="graph" ></div>
CSS
#graph {
background-color:#C0C0C0;
margin: 0 auto;
min-height: 200px ;
min-width: 750px ;
display: inline-block;
}
#graphObject{
display: block;
width: 100%;
}
的Javascript
$(document).ready(function() {
var uri = 'https://api.cosm.com/v2/feeds/120687/datastreams/sensor_reading.png?',
params = {
width: 740,
height: 150,
colour: '#0055ff',
duration: '5minutes',
legend: 'Vibration measure 0 -> 1024 ',
title: 'Foosball Vibrations - 5 Minutes',
show_axis_labels: 'true',
detailed_grid: 'true',
scale: 'manual',
max: 75,
timezone: 'Mountain Time (US & Canada)'
};
var data = uri + $.param(params),
graph = $('#graph'),
obGraph = $('<img/>').prop({'id': 'graphObject'});
var updateGraph = function() {
var date = new Date(),
src = data + '&' + date.getTime();
obGraph.prop('src', '');
obGraph.prop('src', src);
};
graph.empty().append(obGraph);
updateGraph();
setInterval (updateGraph, 1000);
});
有作爲'.reload無此功能()'。您是否嘗試更改源URL(例如,添加「&_rand = 12334234123」)以強制重新加載?另外,當結果是PNG圖像時,爲什麼使用'
試試'$('#graph object')attr。('data',url);'其中'url'是適當資源的路徑。 @ user113215的cache-busting'_rand'可能或可能不是必需的,但應用它比不安全更安全。 –
這是關於它是一個PNG的好點。據我所知,你應該可以使用''標籤而不是'