本文实例讲述了jQuery+Ajax实现限制查询间隔的方法。分享给大家供大家参考,具体如下:
<%@ 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">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Jquery异步查询加载效果</title>
<script src="JS/jquery-1.9.1.js" type="text/javascript"></script>
<link href="Styles/Site.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.span_query { cursor:pointer;}
</style>
<script type="text/javascript">
$(function () {
$(".span_query").click(function () {
var val = $(this).attr("data-value");
var id = $(this).attr("id");
AjaxQuery($(this),val);
});
});
function AjaxQuery(obj, v) {
$.ajax({
url: 'Ajax/Handler.ashx?queryType=score&queryValue=' + v,
type: 'POST',
dataType: 'text',
timeout: 10000,
cache: false,
beforeSend: LoadFunction,
error: erryFunction,
success: succFunction
})
function LoadFunction() {
obj.html('<img src="Images/loading02.gif" />');
}
function erryFunction() {
obj.html('error');
}
function succFunction(tt) {
obj.html('');
obj.html(tt);
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table style="width:100%" class="gvCss">
<tr class="head"><td style="width:10%;">姓名</td><td style="width:30%;">语文</td><td style="width:30%;">数学</td><td style="width:30%;">英语</td></tr>
<tr><td>张三</td>
<td id="query1" title="点击查询" class="span_query" data-value="1">查询</td>
<td id="query2" title="点击查询" class="span_query" data-value="2">查询</td>
<td id="query3" title="点击查询" class="span_query" data-value="3">查询</td></tr>
</table>
</div>
</form>
</body>
</html>
<%@ 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 context)
{
context.Response.ContentType = "text/plain";










