Updating a picture without page reload

前端 未结 6 2020
广开言路
广开言路 2020-12-16 20:41

How would I go about updating an image that gets updated on a server every couple of seconds with out the user having to hit the refresh button, my first guess was ajax but

6条回答
  •  温柔的废话
    2020-12-16 21:30

    Adding a time span to the end of the image URL worked for me.

    var imagePath = "http://localhost/dynamicimage.ashx";

    $("#imgImage").attr("img", imagePath + &ts" + (new Date()),toString() );

提交回复
热议问题