How to make a local refresh of the page?

Source: Internet
Author: User
Tags setinterval

How to organize logically?

1. JS Timer refresh function setinterval (function,time) is required.

2. Only the local labels in the Web page need to be refreshed

function is a custom function, time is how long to execute a custom function, in milliseconds

3. You can make a local refresh by defining a custom function, you need to import jquery

Code demo, how?

    SetInterval (function() {          $ ("#history"). Load (location.href+ "#history >*", "");     2000);

Define a timer, refresh once in 2 seconds, customize function functions each time the refresh executes all content id=history in the Id=history refresh load on the specified Web page

Location.href says refresh this page

Load means loading a webpage, selectively adding some elements to the Web page, load (Url,[data],[callback])

ULR represents the URL #some > selector, is a string, the URL and # have spaces in the middle, specifies that the loaded Url,id=some label,> represents the load, * denotes all, + represents string concatenation

[] represents optional, data data is Key/value form, callback represents callback function, function executed after loading is completed

What are the application scenarios?

  In situations where real-time requirements are high, such as stock trading, airline ticket booking, etc. 

How to make a local refresh of the page?

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.