Front and rear end separation (i)

Source: Internet
Author: User

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)

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.