Home > Web Front-end > JS Tutorial > body text

Ajax implementation of flicker-free scheduled refresh page example code

韦小宝
Release: 2018-01-09 09:56:10
Original
2325 people have browsed it

This article mainly introduces the example code of using Ajax technology to achieve flicker-free scheduled page refresh. It is very good and has the value of reference and learning ajax. Friends who are interested in ajax should read it together

In web development, we often need to refresh a page regularly:

1. To maintain the value of session or check whether the value of session is empty. (For example, to prevent the same user from logging in repeatedly);

2. Real-time in-site text messages;

3. Regularly update page data, etc. However, when we search on the Internet, we will find that there are many ways to refresh the page regularly. The simplest is to add the following code between the tags:

in < Add code between head> tags to achieve regular refresh. I have tested this code and it can achieve the effect

Description: The value of content represents the interval between page refreshes, in seconds.

The value of URL specifies the page to be refreshed

Another way is to use JavaScript to refresh the page regularly

JavaScript to refresh the page regularly, I don’t have this code After testing


<script> 
var limit=":" 
if (document.images){ 
var parselimit=limit.split(":"); 
parselimit=parselimit[]*+parselimit[]*; 
} 
function beginrefresh(){ 
if (!document.images) 
return; 
if (parselimit==) 
window.location.reload(); 
else{ 
parselimit-=; 
curmin=Math.floor(parselimit/); 
cursec=parselimit%; 
if (curmin!=) 
curtime=curmin+" min "+cursec+" sec "; 
else 
curtime=cursec+" sec "; 
window.status=curtime; 
setTimeout("beginrefresh()",); 
} 
} 
window.onload=beginrefresh;
</script>
Copy after login

is added to the middle of the body, here is 0:10 for 10 seconds, you can customize

The above is small The editor introduces to you the example code of Ajax to achieve flicker-free scheduled page refresh. I hope it will be helpful to you! !

Related recommendations:

Ajax refresh problem

Solution to Ajax rollback refresh page problem

Ajax submission Form form page will still refresh j solution

The above is the detailed content of Ajax implementation of flicker-free scheduled refresh page example code. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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