我有一个返回数据的 Web 服务,数据集相当大,可能有 600 行、20 列。
在 Jquery 代码中将此数据加载到 html 表中最快最有效的方法是什么?
我尝试通过循环返回的数据并在字符串中创建表 DOM 来创建表 html,但循环部分非常慢。我听说过 Jquery 模板,但我不确定这项技术对于大型数据集是否足够快......
Thanks
您是否可以更改 Web 服务或让其他服务调用它并解析数据服务器端并返回 HTML?在客户端处理 JSON 将成为您的瓶颈。如果您可以让服务返回所需的 HTML 给您,那么这很简单element.html(data)
在客户端。
编辑:返回 JSON 或 HTML 的问题以及每种方法的优缺点已经在这里讨论了很多:1 https://stackoverflow.com/questions/2186347/load-ajaxdata-in-html-or-json-format, 2 https://stackoverflow.com/questions/3353434/do-you-ajax-json-or-html, 3 https://stackoverflow.com/questions/1148266/ajax-html-vs-xml-json-responses-perfomance-or-other-reasons, 4 https://stackoverflow.com/questions/867163/the-ajax-response-data-json-xml-or-html-snippet, 5 https://stackoverflow.com/questions/1284381/why-is-it-a-bad-practice-to-return-generated-html-instead-of-json-or-is-it
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)