Home Web Front-end JS Tutorial How to achieve flicker-free scheduled page refresh with Ajax

How to achieve flicker-free scheduled page refresh with Ajax

Apr 04, 2018 pm 02:29 PM
ajax timing flashing

This time I will show you how Ajax can achieve flicker-free scheduled refresh page effect. What are the precautions for Ajax to achieve flicker-free scheduled refresh page effect. Here is a practical case, let’s take a look.

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

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

2. Implement real-time in-site text messages;

3. Update page data regularly, 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. It can be customized.

I believe you have mastered the method after reading the case in this article. More exciting Please pay attention to other related articles on php Chinese website!

Recommended reading:

How to use Ajax cross-domain request

Jump to the login page immediately after Ajax+Session fails

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

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to solve the 403 error encountered by jQuery AJAX request How to solve the 403 error encountered by jQuery AJAX request Feb 20, 2024 am 10:07 AM

Title: Methods and code examples to resolve 403 errors in jQuery AJAX requests. The 403 error refers to a request that the server prohibits access to a resource. This error usually occurs because the request lacks permissions or is rejected by the server. When making jQueryAJAX requests, you sometimes encounter this situation. This article will introduce how to solve this problem and provide code examples. Solution: Check permissions: First ensure that the requested URL address is correct and verify that you have sufficient permissions to access the resource.

How to solve jQuery AJAX request 403 error How to solve jQuery AJAX request 403 error Feb 19, 2024 pm 05:55 PM

jQuery is a popular JavaScript library used to simplify client-side development. AJAX is a technology that sends asynchronous requests and interacts with the server without reloading the entire web page. However, when using jQuery to make AJAX requests, you sometimes encounter 403 errors. 403 errors are usually server-denied access errors, possibly due to security policy or permission issues. In this article, we will discuss how to resolve jQueryAJAX request encountering 403 error

A complete solution to the frequent flickering of Win10 computer screen A complete solution to the frequent flickering of Win10 computer screen Jan 16, 2024 pm 08:48 PM

After upgrading to the official version of Win10 and entering the Windows desktop, I found that the screen kept flickering and I could not perform tasks at this time. The editor recently encountered this problem after upgrading to the official version of Win10. After repeated thinking and exploration in the background, the problem was finally solved. Now I will share with you the specific solution. After upgrading to the official version of Win10, most users using the Win10 system have encountered the problem of screen flickering. This is usually due to running incompatible software or a graphics card driver failure. So what causes the Win10 screen to flicker? what can we do about it? The following are solutions to Win10 computer screen flickering. What should I do if my Win10 computer screen keeps flickering? Right-click "This" on the desktop.

PHP and Ajax: Building an autocomplete suggestion engine PHP and Ajax: Building an autocomplete suggestion engine Jun 02, 2024 pm 08:39 PM

Build an autocomplete suggestion engine using PHP and Ajax: Server-side script: handles Ajax requests and returns suggestions (autocomplete.php). Client script: Send Ajax request and display suggestions (autocomplete.js). Practical case: Include script in HTML page and specify search-input element identifier.

Teach you how to set up Win11 scheduled shutdown Teach you how to set up Win11 scheduled shutdown Jan 06, 2024 pm 07:14 PM

Sometimes, we need to leave the computer for a period of time to let it continue to download or allow certain programs, and want to shut down after the operation is completed. So how to set up a scheduled shutdown in win11? In fact, just use the shutdown command. How to set up a scheduled shutdown in win11: 1. First, right-click the start menu in the lower left corner and open "Run" 2. Then enter "shutdown-s-t7200" and press Enter to run. (7200 here is the scheduled shutdown time in seconds, 7200 is the shutdown after 2 hours) 3. In this way, we can complete the scheduled shutdown setting. 4. If you want to cancel the scheduled shutdown, just enter "shutdown-a" and press Enter. 5. After confirmation, you can cancel the scheduled shutdown.

How to solve the problem of jQuery AJAX error 403? How to solve the problem of jQuery AJAX error 403? Feb 23, 2024 pm 04:27 PM

How to solve the problem of jQueryAJAX error 403? When developing web applications, jQuery is often used to send asynchronous requests. However, sometimes you may encounter error code 403 when using jQueryAJAX, indicating that access is forbidden by the server. This is usually caused by server-side security settings, but there are ways to work around it. This article will introduce how to solve the problem of jQueryAJAX error 403 and provide specific code examples. 1. to make

How to get variables from PHP method using Ajax? How to get variables from PHP method using Ajax? Mar 09, 2024 pm 05:36 PM

Using Ajax to obtain variables from PHP methods is a common scenario in web development. Through Ajax, the page can be dynamically obtained without refreshing the data. In this article, we will introduce how to use Ajax to get variables from PHP methods, and provide specific code examples. First, we need to write a PHP file to handle the Ajax request and return the required variables. Here is sample code for a simple PHP file getData.php:

Will setting up scheduled sending on Douyin affect traffic? What is the tutorial on how to set a timer to turn off playback? Will setting up scheduled sending on Douyin affect traffic? What is the tutorial on how to set a timer to turn off playback? Mar 21, 2024 pm 04:51 PM

With the popularity of Douyin, more and more users and companies have begun to pay attention to Douyin marketing. During the operation process, some users asked, will Douyin’s scheduled sending affect traffic? This article will discuss this issue and share a tutorial on how to set a timer to turn off playback on Douyin. 1. Will setting up scheduled sending on Douyin affect traffic? Douyin’s scheduled sending feature allows users to choose to automatically post at a specific time when creating a video. Regarding the impact of this feature on traffic, the official has not yet provided a clear explanation. Based on actual operational experience and analysis, it can be concluded that the impact of the scheduled sending function on traffic can be ignored. The core of Douyin traffic lies in the quality of video content and user interaction, not just the release time. Great content and engaging interactions are key to attracting users’ attention. when

See all articles