ASPMVC,$.getJSON,非常慢
这是我第一个使用 JSON 的游戏,我很惊讶它的速度如此之慢。
我很确定我错过了一些东西,如果有人可以提供帮助,我将不胜感激。
这是我的代码,
$.getJSON('/localhost/CountryList', function (data)
{
alert ("finished");
});
我的 countryList
返回一个像这样的数组
{"Code":"AF","Name":"Afghanistan"},
{"Code":"AX","Name":"Aland Islands"},
{"Code":"AL","Name":"Albania"},
等等......
我的数组的完整大小约为 6K,并且需要超过 1m 30 秒才能由浏览器从我的本地开发中呈现它IIS。
当我使用压缩时,大小变成了2K,但时间仍然是1m 20s
JSON这么慢正常吗?
This is my first game with JSON and I am surprised how slow it is.
I am quite sure I am missing something and I'll be gratefull if someone can help.
Here is my code
$.getJSON('/localhost/CountryList', function (data)
{
alert ("finished");
});
My countryList
returns an array like this
{"Code":"AF","Name":"Afghanistan"},
{"Code":"AX","Name":"Aland Islands"},
{"Code":"AL","Name":"Albania"},
etc....
The full size of my array is about 6K and It takes more than 1m 30s to have it rendered by the browser from my local development IIS.
When I used the compression, the size goes to 2K but the time is still 1m 20s
Is it normal that JSON is so slow?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您能否查看 Firebug 或 Chrome 开发者工具对话框中的交互,看看时间都花在哪里了? AJAX 内容是如何生成的?它是服务器上的静态资源,还是需要进行一些可能很长的数据库魔法的动态工作?是在等待AJAX结果,还是真的在渲染中?
另外,如果您在页面本身本地托管数据(对于本练习来说是暂时的),渲染速度是否相当快?
Can you look at your interaction in Firebug or Chrome's developer tool dialog to see where the time is being spent? How is the AJAX content being generated? Is it a static resource on the server, or is there some dynamic work with some potentially lengthy database magic that needs to take place? Is it waiting for the AJAX result, or is it really in the rendering?
Also, if you host the data locally (and temporarily, for this exercise) in your page itself, is the rendering reasonably fast?