Jquery implements Ajax timed partial page refresh

Source: Internet
Author: User
Tags jquery library

From time to time, I need a mechanism to constantly refresh the webpageProvideA Real-time dashboard.If I can only refresh a part of a specific page, it will be very large. For example, the traffic light on the dashboard shows the system status.

It is easy to use the jquery JavaScript library to refresh only part of the page.Once we include the jquery library of our page, we only need one line of JavaScript to get its work:

 
<SCRIPT src = "/JS/jquery-1.3.2.min.js" type = "text/JavaScript"> </SCRIPT>

So we only need to put our page into this small JSCodeRefresh the Content ID tag in the fragment. Let's say every 5 seconds:

Setinterval (function () {$ ("# Content"). Load (location. href + "# content> *", "") ;}, 5000 );

 

This is it !!Therefore, it is easy to complete some real-time monitoring behaviors, just that line of code.There is no more strange metadata refresh tag or IFRAME solution in Web ApplicationsProgram.

Every 5 seconds, we will refresh the URL with the same content and all elements, resident in the content where the element ID is the content element: content.

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.