Jquery+ajax method to implement limit query interval _jquery

Source: Internet
Author: User

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.

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.