jquery uses $.ajax for asynchronous refresh (with demo download) _jquery

Source: Internet
Author: User

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.

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.