Ajax的诉包括在HTML数据 [英] Ajax v. including data in the HTML

查看:78
本文介绍了Ajax的诉包括在HTML数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用JavaScript使用jQuery,跟一个Django的后端。有需要的Ajax,因为我们无法知道什么样的数据要发送,直到用户提供了一些输入一些UI需求。然而,存在是已知的模板时的其它数据。什么是包括在模板中的数据直接,而是采用了Ajax的利弊?这似乎是前者可能更简单。

I'm using JavaScript with jQuery, talking to a Django back end. There are some UI needs that require Ajax, because we can't know what data to send until the user gives some input. However, there is other data that is known at template time. What are the pros and cons of including that data in the template directly, instead of using Ajax? It seems like the former might be simpler.

推荐答案

在明显的答案的应用是将它们直接包括的虽然我总是建议每处理自己的需要每次使用。记住的页面加载速度的是尽可能多的感觉,因为它是一个可衡量的统计, 尤其在与阿贾克斯的功能处理。

The obvious answer in MOST applications is to include them directly, although I would always recommend treating every usage per its own needs. Remember that 'page load speed' is as much perception as it is a measurable stat, especially when dealing with ajax functionality.

示例

您有载荷和要显示的数据,如果本身包含其与页面实际上将被认为拍摄更多的时间来加载到最终用户比如果加载的初始页面,并把在组块中的数据的负载。您可以在地方认为这是一个替代分页,Facebook的使用和数据的块被带来了作为用户滚动。

You have loads and loads of data to display, if you include it natively with the page will actually be perceived to take much more time to load to the end user than if you load the initial page and bring in the data in chunks. You can see this in place as an alternative to pagination that facebook uses, and the chunks of data are brought in as the user scrolls.

这篇关于Ajax的诉包括在HTML数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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