Home  >  Article  >  Web Front-end  >  Solve the problem of jquery asynchronously refreshing at a certain time interval_jquery

Solve the problem of jquery asynchronously refreshing at a certain time interval_jquery

WBOY
WBOYOriginal
2016-05-16 17:47:03868browse

I want to refresh the pictures on a web page at a certain time interval without changing the name of the picture. I change the content of the picture on the server side. Can the front end achieve dynamic effects in this way? Does the browser have a cache?
For example, if I want to refresh the picture below asynchronously, what should I do?

Copy code The code is as follows:



The solution is to add a timestamp to prevent caching, as follows:
Copy code The code is as follows:



JScript code :
Copy code The code is as follows:

setInterval(function(){document.getElementById(' image').src='xxx.jpg?_dc=' new Date().getTime()},5000);//Update every 5s

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn