如何使图像自动刷新以获得新的渲染视图?而不是浏览器缓存

时间:2013-06-05 15:39:28

标签: php javascript jquery google-chrome opera

我有以下html代码使用jQuery进行刷新,但它没有在chrome浏览器中显示新图像。

For example: 12.00AM - RED CAR driving
<div class="mycam_local">
          <img src="http://192.168.0.181:8008/liveimage/now.jpeg?1370446579000">
</div>

For example: 04.00AM - still RED CAR (basically its yellow one)
<div class="mycam_local">
          <img src="http://192.168.0.181:8008/liveimage/now.jpeg?1350446549000">
</div>

修改

$('.my_camera_brightness_up').live("click", function() {
  if (myb>1) {
    myb=1;
  } else {
    myb=myb+0.01;
  }    

  $.ajax({
    type    : "GET",//POST
    dataType: 'json',
    url     : '/a/c',
    data    : url + '&command=brightness;'+myb.toFixed(2),
    async   : true,
    beforeSend: function()
    {

    },
    complete: function()
    {            
    },
    success : function(msg)
    {
      $('.my_camera_buttonstate').html("Updated: " + myb.toFixed(2));
      var xy= "<img src=\"http://" + msg.extra.remoteip + ":7007/video/now.jpeg?"+ Date.parse(new Date().toString() ) + "\" />";
      //$('.mycam_local').find('img').attr('src',  'http://' + msg.extra.remoteip + ':7007/video/now.jpeg' +"?"+ Date.parse(new Date().toString()) );
      alert(xy);
      $('.mycam_lcoal').html(xy);
    }
  });    
});

1 个答案:

答案 0 :(得分:2)

您可以尝试使用此解决方法:

$('.mycam_remote').find('img').attr('src','').attr('src', 'http://' + msg.extra.remoteip + ':7007/video/now.jpeg' +"?"+ Date.parse(new Date().toString()));

看看它是否适合你