ajax耗时,Ajax请求耗时太长

我问你,因为我没有任何想法......

我做了一个ajax请求,从服务器获取一个小数据。 json的答案已经被服务器缓存了,所以速度非常快。

window.xhr = $.ajax({

url: domain+'index.php?fx_action=ajax&fx_mode=continents&fx_type=countries&fx_ajaxid='+window.currentajaxrequest+'&fx_id='+window.id+'&fx_page='+(window.page-1)+'&fx_pager='+window.pager+'&fx_order='+window.order,

type: 'POST',

dataType: 'json',

timeout: 5000,

cache: false,

async: true,

beforeSend: function () {

...

},

error: function (xhr, ajaxOptions, thrownError) {

return false;

},

success: function (data) {

...

但答案时间大幅缩小,有时需要1秒,有时只需67毫米......

continents.js:65 http://teszt.domain.com/index.php?fx_action=ajax&fx_mode=continents&fx_type=countries&fx_ajaxid=0&fx_id=6&fx_page=1&fx_pager=9&fx_order=name

continents.js:100 start: 0

continents.js:101 beforesend: 9

continents.js:102 success: 5087

continents.js:103 complete: 5096

continents.js:65 http://teszt.domain.com/index.php?fx_action=ajax&fx_mode=continents&fx_type=countries&fx_ajaxid=1&fx_id=6&fx_page=2&fx_pager=9&fx_order=name

continents.js:100 start: 0

continents.js:101 beforesend: 9

continents.js:102 success: 70

continents.js:103 complete: 77

continents.js:65 http://teszt.domain.com/index.php?fx_action=ajax&fx_mode=continents&fx_type=countries&fx_ajaxid=2&fx_id=6&fx_page=3&fx_pager=9&fx_order=name

continents.js:100 start: 0

continents.js:101 beforesend: 11

continents.js:102 success: 301

continents.js:103 complete: 304

获得具有几乎相同大小(kbytes)的相同数据结构。一切都由服务器缓存。

在服务器端,php的运行时间总是大约30-40ms。我的错是什么?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值