Ajax Implementation page Automatic refresh instance resolution _ajax related

Source: Internet
Author: User
Tags echo date jquery library

Introduction to Ajax:

Ajax, "Asynchronous JavaScript and XML" (Asynchronous JavaScript and XML), refers to a web development technology that creates interactive Web applications.
AJAX = Asynchronous JavaScript and XML (a subset of standard generic markup languages).

AJAX is a technique for creating fast-moving web pages.

AJAX enables asynchronous updating of Web pages by making a small amount of data exchange in the background with the server. This means you can update portions of a Web page without reloading the entire page.

Traditional Web pages (without AJAX) if you need to update the content, you must overload the entire page page.

HTML section:

<! DOCTYPE html>  

PHP page Section

<?php
 $count =$_get["Count"];
 $count = $count%7;
  Switch ($count) {case
    1: $message = "11111111111111111";
    Case 2: $message = "22222222222222222";
    Case 3: $message = "33333333333333333";
    Case 4: $message = "44444444444444444";
    Case 5: $message = "55555555555555555";
    Case 6: $message = "66666666666666666";    
  $res = $message;
  echo Date ("Y-m-d h:i:s"). "  
 

Effect Chart:


Here's a description of jquery implementation Ajax timed local page refresh

Sometimes, I need some kind of mechanism to keep refreshing the pages to provide a real-time dashboard. If I can only refresh a particular part of the page, it will be great, for example: the traffic lights on the dashboard show the system state.

It is easy to refresh a part of the page by using the jquery JavaScript library only. Once we've incorporated our page into the jquery library, we only need 1 lines of JavaScript to get it working:

 
 

So we just put our page into this little JS code snippet to refresh the contents of the ID tag in everything, let's say, every 5 seconds:

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

That's it!! Therefore, it is very easy to complete some real-time monitoring behavior, just that line of code. No more bizarre meta refresh tags or iframe a workaround in the Web application.

Every 5 seconds, we will refresh the same URL and all elements that reside in the Content element ID: 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.