我正在研究一个ASP.NET应用程序,我需要jQuery AutoComplete。当我在txt63输入框输入数据时(,以及在使用像txt63这样的名字之前,我知道,我知道......但它不是我的电话:D),目前没有任何事情发生。无法让jQuery AutoComplete与外部JSON一起工作
这里是我的javascript代码
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js" type="text/javascript"></script>
<script src="http://jquery-ui.googlecode.com/svn/tags/latest/external/jquery.bgiframe-2.1.1.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/i18n/jquery-ui-i18n.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
var theSource = '../RegionsAutoComplete.axd?PID=<%= hidden62.value %>'
$(function() {
$('#<%= txt63.ClientID %>').autocomplete({
source: theSource,
minLength: 2,
select: function (event, ui) {
$('#<%= hidden63.ClientID %>').val(ui.item.id);
}
});
});
,这里是我的HTTP处理程序
Namespace BT.Handlers
Public Class RegionsAutoComplete : Implements IHttpHandler
Public ReadOnly Property IsReusable() As Boolean Implements System.Web.IHttpHandler.IsReusable
Get
Return False
End Get
End Property
Public Sub ProcessRequest(ByVal context As System.Web.HttpContext) Implements System.Web.IHttpHandler.ProcessRequest
''# the page contenttype is plain text'
context.Response.ContentType = "application/json"
context.Response.ContentEncoding = Encoding.UTF8
''# set page caching'
context.Response.Cache.SetExpires(DateTime.Now.AddHours(24))
context.Response.Cache.SetCacheability(HttpCacheability.Public)
context.Response.Cache.SetSlidingExpiration(True)
context.Response.Cache.VaryByParams("PID") = True
Try
''# use the RegionsDataContext'
Using RegionDC As New DAL.RegionsDataContext
''# query the database based on the querysting PID'
Dim q = (From r In RegionDC.bt_Regions _
Where r.PID = context.Request.QueryString("PID") _
Select r.Region, r.ID)
''# now we loop through the array'
''# and write out the ressults'
Dim sb As New StringBuilder
sb.Append("{")
For Each item In q
sb.Append("""" & item.Region & """: """ & item.ID & """,")
Next
sb.Append("}")
context.Response.Write(sb.ToString)
End Using
Catch ex As Exception
HealthMonitor.Log(ex, False, "This error occurred while populating the autocomplete handler")
End Try
End Sub
End Class
End Namespace
我的ASPX页面的其余部分有适当的控制,因为我有这个与旧版本的jQuery工作图书馆。我试图让它与新的一起工作,因为我听说“dev”CDN将会过时。
任何帮助或方向将不胜感激。
我认为txt63是一个崇高的名字发表评论,我的名字我的第63个孩子这个欢乐的名字,并指责另一个我不能命名为别的:d – Gabriel 2010-05-31 05:12:22
刚澄清。网站所有者已经构建了需要与此应用程序接口的应用程序和数据结构。数据库表只是一堆数字50 - 250或像这样一些愚蠢的东西。如果我要使用名字,那么我必须为下一个将名称映射到数据库的人建立一个参考指南......这样做更有意义。 – 2010-05-31 05:16:06