The example in this article describes the Jquery+ajax method for implementing a limit query interval. Share to everyone for your reference, specific as follows:
<%@ Page language= "C #" autoeventwireup= "true" codefile= "Jquery20150305.aspx.cs" inherits= "Jquery20150305"%> <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<%@ WebHandler language= "C #" class= "Handler"%> using System;
Using System.Web;
Using System.Web.SessionState; Handler.ashx public class Handler:ihttphandler, irequiressessionstate {public void ProcessRequest (HttpContext conte XT) {context.
Response.ContentType = "Text/plain"; string querytype = context.
request["QueryType"]; String queryvalue = context.
request["QueryValue"]; if (context. session["prequery"] = = NULL)//First query {context.
session["prequery"] = QueryValue + "@" + DateTime.Now.AddDays (-1); Context.
session["currquery"] = QueryValue + "@" + DateTime.Now; else//exists last query {string[] Prestrs = context. session["Currquery"]. ToString ().
Split (' @ '); Context. session["prequery"] = QueryValue + "@" + prestrs[1]; Reset to current query parameters + last query time context.
session["currquery"] = QueryValue + "@" + DateTime.Now; } string[] Strs=context. session["Prequery"]. ToString ().
Split (' @ ');
if (strs[0] = = queryvalue)//The same request limit query interval {DateTime pretime = Convert.todatetime (strs[1]);
DateTime nowtime = DateTime.Now;
BOOL flag = Checkquerytimespan (Pretime, Nowtime, 3); if (flag) {context.
Response.Write ("Query interval 3 seconds"); } else {context.
Response.Write ("98"); }} context.
Response.End (); ///<summary>///To determine if this query and last query interval is less than the specified number of seconds///</summary>///<param name= "Pretime" > Last Query Time </pa ram>///<param name= "Nowtime" > This time </param>///<param name= "TimeSpan" > The specified number of seconds </param>///
<returns></returns> public bool Checkquerytimespan (datetime pretime, datetime nowtime, int timeSpan) {
TimeSpan ts = nowtime-pretime; int difference = ts.
Seconds; BOOL flag = (Difference < TimeSpan)?
True:false;
return flag;
public bool IsReusable {get {return false;
}
}
}
More interested readers of jquery-related content can view the site's topics: A summary of Ajax usage in jquery, a summary of jquery table (table) operations tips, a summary of jquery drag-and-drop effects and techniques, a summary of jquery extension techniques, jquery Common Classic Effects Summary "jquery animation and special effects usage Summary", "jquery selector usage Summary" and "jquery common Plug-ins and Usage summary"
I hope this article will help you with the jquery program design.