Home > Web Front-end > JS Tutorial > 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
Release: 2016-05-16 17:47:03
Original
906 people have browsed it

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

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template