The example in this article describes the way jquery uses $.ajax for instant validation. Share to everyone for your reference, specific as follows:
This implementation uses jquery and general handlers to instantly verify that the number of user input is duplicated and prompts when the cursor leaves the input box.
<%@ Page language= "C #" autoeventwireup= "true" codefile= "AddStudent.aspx.cs" inherits= "addstudent"%> <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
Generic Handler Check.ashx code:
<%@ WebHandler language= "C #" class= "Check"%>
using System;
Using System.Web;
public class Check:ihttphandler {public
void ProcessRequest (HttpContext context) {context
. Response.ContentType = "Text/plain";
String num = context. request["Txtnum"]. ToString ();
BOOL result = FALSE;
if (num== "12")//To simplify the code, there is no access to the database. The actual project should query the database.
{Result
= true;
}
Context. Response.Write (result);
}
public bool IsReusable {get
{return
false;
}}}
I hope this article will help you with the jquery program design.