First, the basic knowledge
1. Ajax is the abbreviation for asynchronous JavaScript and XML, which is asynchronous JavaScript and XML. Traditional Web pages (without Ajax) you must reload the entire Web page if you need to update the content. Ajax is a technique that can update parts of a Web page without reloading the entire page.
2. General processing Program: This program with the extension ashx in the ASP. NET site is called "Generic handler", which differs from the normal form page program with an ASPX extension, which is a form page code that has no HTML and is suitable for processing data as a background server.
Second, Ajax-demo
Client.html
<! DOCTYPE html>1, loading a picture in the same directory
2. Each click on the "Get" button will send an asynchronous request like the server side
Server.ashx
<%@ WebHandler language= "C #" class= "Demo.server" debug= "true"%>using system;using system.web;using System.threading;namespace Demo{public class Server:ihttphandler {public bool isreusable { get { return false; } } public void ProcessRequest (HttpContext context) { String s = DateTime.Now.ToString ("Yyyy-mm-dd HH:mm:ss"); Thread.Sleep (+); Output result context. Response.Clear (); Context. Response.ContentType = "Text/plain"; Context. Response.Write (s); Context. Response.Flush ();}}}
When a request comes in, get the current time and then pass it back to the client (more complex functions can be extended on this basis)
Web. config
<?xml version= "1.0" encoding= "Utf-8"?><configuration> <system.web> <globalization requestencoding= "gb2312" responseencoding= "gb2312"/> </system.web></configuration>
Front and rear end separation (i)