The example in this article describes the way jquery uses $.ajax for asynchronous refreshes. Share to everyone for your reference, specific as follows:
With the recent function of using jquery to read data asynchronously, jquery provides many built-in asynchronous read functions to demonstrate the most common $.ajax usage
Enter a content in the Client text box, and then return the time on the server side
Use the Ashx file in the demo to get information about the server
Effect picture
The escape () function encodes the string so that it can be read on all computers.
Client code
<%@ Page language= "C #" autoeventwireup= "true" codefile= "Default7.aspx.cs" inherits= "Default7"%> <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
Server-side code
<%@ WebHandler language= "C #" class= "ContentHandler"%>
using System;
Using System.Web;
public class Contenthandler:ihttphandler {public
void ProcessRequest (HttpContext context) {
string output = "" ;
String name = Context. request.params["name"];
Output = Getjsondata (name);
Context. Response.ContentType = "Text/plain";
Context. Response.Write (output);
}
public bool IsReusable {get
{return
false;
}
}
public string Getjsondata (String aa)
{
string result = "{name:/" "+aa+"/", dt:/" "+datetime.now.tostring () +"/ "}";
return result;
}
Full instance code click here to download the site.
I hope this article will help you with the jquery program design.