Use Ajax to regularly refresh Page code without blinking, and use ajax to refresh the page

Source: Internet
Author: User

Use Ajax to regularly refresh Page code without blinking, and use ajax to refresh the page

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

1. To keep the session value or check whether the session value is null (for example, to prevent repeated login by the same user );

2. implement real-time intra-site SMS;

3. Regularly update page data. However, you may find many ways to regularly refresh the page. The simplest method is to add the following code between the

Code is added between the

<Meta http-equiv = "refresh" content = "5" URL = "Example. aspx"/>

Note: The content value indicates the page refresh interval, in seconds.

URL value specifies the page to be refreshed

Another method is to use JavaScript to regularly refresh the page.

Regularly refresh the page with JavaScript. I have not tested this code.

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

It is added to the center of the body. The value 0: 10 is 10 seconds. It can be customized.

The above is the example code for refreshing the page without flashing the Ajax implementation introduced by xiaobian. I hope it will be helpful to you. If you want more information, please stay tuned to the help House website!

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.