当使用 AjaxControlToolkit AutoCompleteExtender 发送太快时,Ajax 请求将被中止
我正在 asp.net ajax 上使用示例 AutoCompleteExtender网站,我遇到了不必要的行为。首先我想说的是,来自 asp.net 站点的示例实在是太慢了。 1 秒的 CompletionInterval 对我来说太长了。因此,我将其降低到 300 毫秒,现在我收到了这些请求中止的消息。 Firebug 向我展示了这个:
POST http://localhost:49539/AutoComplete.asmx/GetCompletionList Aborted
当请求被中止时,它显然无法检索新列表,因此不会显示选项列表,这会导致用户体验不佳。如果我打字速度很慢,那么请求就会顺利完成,并且我会得到选项列表。似乎我需要完成每个请求才能为用户提供最佳体验,但请注意...
有人知道我需要做什么才能始终在输入字母后 100-400 毫秒内弹出列表?
注意:看起来 IE 和 Chrome 没有中止请求,因此我得到了更好的响应时间,并且列表立即弹出。这可能是一个侥幸,在另一台计算机上的工作方式有所不同 - 我不知道。
另请注意:我的 GetCompletionList() 函数非常基本,仅返回硬编码值(无数据库请求),因此速度非常快。
这是.aspx
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server" autocomplete="off"></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
TargetControlID="TextBox1"
ServicePath="~/AutoComplete.asmx"
ServiceMethod="GetCompletionList"
MinimumPrefixLength="1"
CompletionInterval="200"
CompletionSetCount="12"
EnableCaching="true">
</ajaxToolkit:AutoCompleteExtender>
</ContentTemplate>
</asp:UpdatePanel>
I'm using the sample AutoCompleteExtender on the asp.net ajax site and am running into unwated behavior. First let me just say the sample from the asp.net site is just too dang slow. The 1 second CompletionInterval is too long for my taste. So I lower it to 300 ms and now I get these request aborted messages. Firebug shows me this:
POST http://localhost:49539/AutoComplete.asmx/GetCompletionList Aborted
When the request is aborted, it obviously fails to retrieve the new list and thus not displaying the list of options which makes for a poor user experience. If I type slowly, then the requests go through fine and I get the list of options. It seems like I need every request to complete to give the user the best experience, but note sure...
Does anyone know what I need to do to always make the list pop up within 100-400 ms of typing a letter?
Note: It looks like IE and Chrome are not aborting the requests and thus I get a much better response time and the list pops up right away. This may be a fluke and work differently on another computer - I don't know.
Also note: My GetCompletionList() function is very basic and only returns hard coded values (no DB requests), so it's very fast.
Here's the aspx
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server" autocomplete="off"></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
TargetControlID="TextBox1"
ServicePath="~/AutoComplete.asmx"
ServiceMethod="GetCompletionList"
MinimumPrefixLength="1"
CompletionInterval="200"
CompletionSetCount="12"
EnableCaching="true">
</ajaxToolkit:AutoCompleteExtender>
</ContentTemplate>
</asp:UpdatePanel>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于几周以来没有人回答我的问题,我会尝试一下。
我不能 100% 确定这是我的问题,但我倾向于认为这是由 Visual Studio 附带的 Web 服务器引起的。我在另一个项目中遇到了类似的问题,但它是托管在本地 IIS 服务器上(更改 Web 选项卡下的项目属性)并且请求没有被中止。
我不能 100% 确定的原因是该项目使用了一个 jquery 库,该库在使用 Visual Studio 内置的 Web 服务器时会收到中止请求,但在使用本地 IIS 服务器时不会收到中止请求。
Since nobody has answered my question for weeks now, I'll give it a shot.
I'm not 100% sure this was my problem, but I'm inclined to think it was caused by the web server that ships with visual studio. I had a similar problem with another project but it was hosted on the local IIS server (change the project properties under the web tab) and the requests weren't getting aborted.
The reason I'm not 100% sure is the project was using a jquery library that was getting abort requests when using the visual studio built in web server, but not so when using the local IIS server.