简体   繁体   中英

JSON or XML or other data format with jQuery ajax()?

对于数据发送,返回数据包含页面上数百个元素的潜在更新,XML或JSON或其他数据格式是否更好,可与jQuery的各种解析格式配合使用(通过ajax()成功调用)?

Check out this article , it outlines various pros/cons of XML, JSON and HTML when processing AJAX requests.

Personally I'd pick JSON as it uses less bandwidth & is easier to parse and use.

It sounds like a lot of data being returned so json. It's lighter and more compact. Plus it has native use instead of having to parse the xml and traverse it afterwards.

在javascript中,最好使用JSON,因为它更易于编码,并且从服务器加载的数据更少,与XML不同,您必须编写代码来解析元素并将值取到对象以及数据标签中的每个更改或XML中的元素,您将需要修改javascript代码,这意味着需要进行更多的编码和测试,与JSON不同,您所需的全部是eval(),您就可以开始使用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM