"JavaScript" uses the SetInterval () function as a simple polling operation

Source: Internet
Author: User

Polling (Polling) is a way for a CPU decision to provide peripheral device services, also known as "programmed output in" (Programmed I/O). The concept of polling is that the CPU timed to ask, in sequence to ask each of the peripheral devices need their services, there is to give services, after the end of the service to ask the next perimeter, and then continue to cycle. The polling method is easy to implement, but less efficient.

In JavaScript using the SetInterval function for a simple polling operation, you can determine the value of a parameter at any time, but do not have to refresh the page, that is, do not add <meta http-equiv= "Refresh" content= "5" in the header > Make a decision to refresh the page.


I. BASIC OBJECTIVES

An input box without the onchange () function, directly using the SetInterval function as a simple polling operation, not 0.5 seconds to read the contents of the text box


In fact, the same principle as the JavaScript clock, every second to take the current time, and then update the text content


Second, the production process

The code below, no longer repeat:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
The polling () function begins execution after the page is loaded, executes the synchronous () function, and then executes the synchronous () once every 0.5 seconds;

"JavaScript" uses the SetInterval () function as a simple polling operation

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.