脚本宝典收集整理的这篇文章主要介绍了php – 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.我的错是什么?
@H_404_4@以上是脚本宝典为你收集整理的php – Ajax请求耗时太长全部内容,希望文章能够帮你解决php – Ajax请求耗时太长所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。