我应该使用JSON或AJAX的响应数据? [英] Should I use JSON or AJAX for response data?
问题描述
为什么JSON?我已经做了一些试验今天,和请求时间为JSON或一个正常AJAX请求是相同的。在正常请求我回来了完整的文本+ html标签,以JSON的要求,在逻辑上我又回到了json的返回类型,我已创建了客户端JavaScript的HTML。
Why JSON? I have done some tests today, and the request time for both JSON, or a normal AJAX request was the same. In the "normal request" I have returned the complete text+html tags, in the JSON request, logically I returned a "json return type" and I have created the HTML with client-side JavaScript.
我不明白,为什么大网站(谷歌阅读器等),或者使用JSON哪怕是很小的网站?或者我不明白的时候,我应该使用JSON?
I don't get it, why are the big sites (Google Reader etc), or even small sites using JSON? Or do I not understand when I should use JSON?
推荐答案
您也许有点糊涂了。
JSON和AJAX不是一个非此即彼的选择。
JSON and AJAX are not an either-or choice.
JSON和XML是一种选择。
JSON and XML is a choice.
JSON和AJAX是不同的,在很大程度上不相关,虽然AJAX经常使用JSON,它可以只是轻松地使用XML,HTML或纯文本。
JSON and AJAX are distinct and largely unrelated, although AJAX often uses JSON, it can just easily use XML, HTML or plain text.
或者,你指的X,AJAX(XML)?如果是这样,对JSON的参数基本上是:
Or are you referring to the X in AJAX (XML)? If so, the arguments for JSON are basically:
- 在JSON具有较小的载荷比等价的XML;和
- 在JSON是更容易处理的Javascript(比较eval'ing JSON对象行走XML片段)。
除此之外,它的主要是个人preference。
Other than that, it's largely personal preference.
这篇关于我应该使用JSON或AJAX的响应数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!