Ajax implementation without Flicker timed Refresh page instance code _ajax related

Source: Internet
Author: User

In web development we often need to implement a timed refresh of a page:

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

2. Realize the real-time message in the station;

3. Regularly update page data and so on. But we search on the Internet will find a lot of time to refresh the page, the simplest way is to add the following code between

Add code between

<meta http-equiv= "Refresh" content= "5" url= "example.aspx"/>

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

The value of the URL specifies the refreshed page

Another way is to use JavaScript to refresh the page regularly

JavaScript periodically refreshes the page, this code I have not tested

<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>

Add to the center of the body, here is 0:10 for 10 seconds, you can customize

The above is a small set to introduce Ajax to achieve flicker-free time page instance code, hope to help everyone, if you want to learn more information please pay attention to cloud Habitat community website!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.