JQuery AJAX slows down in Firefox, fast in IE

I am using jQuery to publish to an ASP.NET web service to implement a custom autocomplete function. The code works fine, except that it is slow in FireFox (cannot make it work faster than 1 second). IE is blazing fast - works great. I am watching a post in Firefox using Firebug.

Here's the service code:

<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 

And jQuery ajax call:

 $.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 }); 

As you can see, I tried using the HTTP GET verb instead in the hope that this would speed up the call. Since this is not the case, I will probably return to using POST if I can. Right now, I'm just focusing on why it is super fast in IE and super slow in Firefox.

Versions: jQuery 1.3.2; Firefox 3.0.11; IE 8.0.6001.18783 (64-bit)

Thanks for any information you can provide.

+4
source share
5 answers

Therefore, instead of just clicking “Run” in Visual Studio, I created the application in IIS and got access to this page - now it works quickly in both FireFox and IE. Strange ... I'm still a little wary of this - I have a feeling that it can come back to haunt me somewhere, but at the moment it seems that the problem is solved.

+2
source

I know I'm late for a party on this, but I just had to deal with a similar situation. Turns out the “problem” was using http: // localhost instead of 127.0.0.1

IE ran quickly using any URL. FF quickly used the IP address, but added 1 second delay using localhost.

+4
source

I bet that IE caches it. For some reason, IE is a bit more aggressive (old post, but I still see the problem) when it comes to caching, and this is probably no exception. Try running some sanity checks to see if it really caches it.

+1
source

Sorry, I'm late for this question too. Cassini (VS Web Server) + Firefox has known performance issues for any server request (not just ajax / webservice requests). Solution 127.0.0.1 is one fix - another is to change the setting in firefox:

http://blog.anofsinger.com/2007/08/firefox-slowness-with-cassini-vs-web.html

+1
source

Is there a reason you are using beforeSend :?

You can simply specify the content type as a parameter, for example:

contentType: "application / json; charset = utf-8"

Also, why not make the URL of the web method relative or absolute? I doubt that a complete uri will make a difference, but you never know.

0
source

Source: https://habr.com/ru/post/1286692/


All Articles