Soft Technology Web Classroom: AJAX Introduction

 AJAX

AJAX is not a programming language.

AJAX is a Web server from accessing web technology.

AJAX Asynchronous JavaScript and representatives of XML.

AJAX example explained

HTML page

<! DOCTYPE HTML> 
<HTML> 
<body> 

<div the above mentioned id = "Demo"> 
  <h2> Let AJAX change this text </ h2> 
  <the Button of the type = "the Button" onclick = "loadDoc ()"> Change the text < / Button> 
</ div> 

</ body> 
</ HTML>

This HTML page contains a <div> and a <button>.

<Div> for displaying information from the server.

<Button> call the function (when it is clicked).

This function requests data from a web server and display it:

Function loadDoc()

function loadDoc() {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
     document.getElementById("demo").innerHTML = this.responseText;
    }
  };
  xhttp.open("GET", "ajax_info.txt", true);
  xhttp.send();
} 

 

What is AJAX?

AJAX = Asynchronous JavaScript And XML.

AJAX is not a programming language.

AJAX is just a combination of:

  • Integrated with the browser XMLHttpRequest object (requesting data from a web server)
  • JavaScript and HTML DOM (or display data)

Ajax is the name of a very misleading. Ajax applications can use XML to transfer data, but the data as plain text or JSON text transmission is also common.

Ajax allows the exchange of data with the server behind the scenes to asynchronously update the Web page. This means that the section of the page can be updated without the need to reload the entire page.

How AJAX work

  1. The occurrence of an event web page (the page loads, click on the button)
  2. Created by the JavaScript XMLHttpRequest object
  3. XMLHttpRequest object sends a request to the web server
  4. Server processes the request
  5. The server sends a response back to the web page
  6. Read the response from the JavaScript
  7. JavaScript is executed by the proper action (such as updating the page)

Guess you like

Origin www.cnblogs.com/sysoft/p/12164759.html