请求时序在`$ .ajax`有时是上面的1秒,有时是30毫秒 [英] Request Timing in `$.ajax` is sometimes above 1 second and sometimes 30ms

查看:225
本文介绍了请求时序在`$ .ajax`有时是上面的1秒,有时是30毫秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用在Windows 7上我试图这样做,当你点击保存的图像将发送信息在后台save_record.php XAMPP版本1.7.7。我这样做是有

I am using xampp version 1.7.7 on windows 7. I am trying to do that when you click save image it would send information to save_record.php in the background. I do this with

$.ajax({
      url: 'save_record.php',
      data: values.join("&"),
      success: function(data) {
            //document.write(data);
          }
    });

和它显然不是问题。的问题是,反应速度非常慢,我无法找到它的原因。下面我添加数据,我从铬的速度示踪好评。萤火虫也呈现出超过1一个all响应。它们有像1055ms和1035ms格式,让我觉得它得到的地方停留一秒钟。如果这还不够奇怪,它开始发出请求快速(30-50ms的)在一定的时间,这是一个非常有用的应用程序对我来说。否则,一个1秒的延迟杀死它。有一次我杀了explorer.exe进程,并加入一个新的任务和它的工作。但下一次它没有。我重新启动电脑 - 它为一秒......虽然我打字这个问题就开始做那些快的要求。一旦开始做他们很快这一切都很好,但是当我开始XAMPP(或从睡眠状态中打开我的笔记本电脑),它通常是慢(1秒+)。这是一段时间后有点自我解决问题(如5-10mins通常情况下),但它是非常讨厌,既好奇,为什么发生这种情况:)希望我很清楚这个问题。

And it is clearly not the issue. The problem is that the response is very slow and I am unable to find the reason for it. Below I add the data I received from chrome speed tracer. Firebug is also showing all responses above 1 second. They come in format like 1055ms or 1035ms which makes me think it gets stuck somewhere for one second. If that was not weird enough, it starts making the requests fast (30-50ms) at some time and that is a perfectly usable application for me. Otherwise that 1 second delay is killing it. I once killed process explorer.exe and added as a new task and it worked. But the next time it didn't. I restarted the pc - it is one second... And while I was typing this question it started doing those fast requests. Once it starts doing them fast it's all good, but when I start xampp (or open my laptop from sleep) it is usually slow (1sec+). This is a somewhat self solving problem after some time (like 5-10mins usually), but it is annoying and both curious as why this is happening :) Hopefully I was clear about the problem.

P.S。我测试,从第一个PHP标记时间上的差异,以最后一个是〜20毫秒,所以我认为它不是PHP缓存的作用了?

P.S. I tested and the difference in time from first php tag to last one is ~20 ms, so I assume it is not PHP cache that is acting up?

P.S.2。我将提供所需的任何其他数据,只是不知道该怎么看:)只是名字。

P.S.2. I would provide any other data needed, just not sure what to look at :) Just name it.

更新:加入Chrome的网络标签

UPDATE: added Chrome's network tab.

更新:XAMPP的重新安装后问题仍然存在:

UPDATE: after reinstallation of xampp the problem still persists:

推荐答案

取消注释行 127.0.0.1本地主机 C:\ Windows \ System32下\ DRIVERS \等\主机解决了这个问题。速度只是跳起来难以置信。我发现这个建议在这里。其实Chrome的开放其他页面甚至速度提高了很多OO

Uncommenting the line 127.0.0.1 localhost in C:\Windows\System32\drivers\etc\hosts solved the problem. The speed just jumped up incredibly. I found this advice in here. Actually even the speed of Chrome opening other pages increased a lot o.O

这篇关于请求时序在`$ .ajax`有时是上面的1秒,有时是30毫秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆