加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – jQuery AJAX在Firefox中速度慢,在IE中速度很快

发布时间:2020-12-16 06:35:19 所属栏目:asp.Net 来源:网络整理
导读:我正在使用jQuery发布到ASP .NET Web服务来实现自定义自动完成功能.代码效果很好,除了它在FireFox中速度慢(不能让它超过1秒). IE非常快 – 效果很好.我使用Firebug在Firefox中观看帖子. 这是服务代码: ScriptService(),_WebService(Namespace:="http://temp
我正在使用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; Firefox 3.0.11; IE 8.0.6001.18783(64位)

感谢您提供的任何见解.

解决方法

我知道我迟到了这个问题的党,但我只是处理类似的情况.事实证明’问题’是使用 http://localhost而不是127.0.0.1

IE使用任一URL快速执行. FF使用IP地址很快,但使用localhost增加了1秒的延迟.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读