【发布时间】:2009-06-24 16:36:47
【问题描述】:
我正在使用 jQuery 发布到 ASP .NET Web 服务以实现自定义自动完成功能。该代码工作得很好,除了它在 FireFox 中的速度很慢(不能让它快于 1 秒)。 IE 速度极快 - 效果很好。我使用 Firebug 在 Firefox 中观看帖子。
这是服务代码:
<ScriptService(), _
WebService(Namespace:="http://tempuri.org/"), _
WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1), _
ToolboxItem(False)> _
Public Class TestWebSvc
Inherits System.Web.Services.WebService
<WebMethod(), _
ScriptMethod(ResponseFormat:=Script.Services.ResponseFormat.Json, UseHttpGet:=True)> _
Public Function GetAccounts(ByVal q As String) As Object
'Code taken out for simplicity
Return result
End Function
End Class
还有 jQuery ajax 调用:
$.ajax({
beforeSend: function (req) { req.setRequestHeader("Content-Type", "application/json"); },
contentType: "application/json; charset=utf-8",
type: "GET",
url: "http://localhost/Suggest/TestWebSvc.asmx/GetAccounts",
data: "q='" + element.val() + "'",
dataType: "json",
success: testWebSvcSuccess
});
如您所见,我尝试改用 HTTP GET 动词,希望这样可以加快调用速度。因为它没有,如果可以的话,我可能会将它切换回使用 POST。现在我只关注为什么它在 IE 中超级快而在 Firefox 中超级慢。
版本:jQuery 1.3.2;火狐 3.0.11; IE 8.0.6001.18783(64 位)
感谢您提供的任何见解。
【问题讨论】:
-
挂起或禁用萤火虫时仍然很慢?我注意到使用 firebug 会对性能产生严重影响。
-
是的,即使我禁用 Firebug 也一样慢。
标签: asp.net asp.net-ajax jquery asmx