ajax - 何时将 Ajax 与 Json 用于 Javascript 事件?

我对 Ajax 不是很熟悉,但我经常听到有人提到 Json 作为某种竞争选项。有没有规定何时使用一种与另一种?

我想在我的应用程序中处理 Javascript 事件并从应用程序动态更新前端,但我不确定是否需要为此使用 Ajax 或 Json。

最佳答案

Ajax和 JSON是非常不同的东西。

来自 Ajax (programming) :

Ajax, sometimes written as AJAX (shorthand for asynchronous JavaScript and XML), is a group of interrelated web development techniques used on the client-side to create interactive web applications or rich Internet applications. With Ajax, web applications can retrieve data from the server asynchronously in the background without interfering with the display and behavior of the existing page. The use of Ajax has led to an increase in interactive animation on web pages and better quality of Web services thanks to the asynchronous mode. Data is retrieved using the XMLHttpRequest object. Despite the name, the use of JavaScript and XML is not actually required, nor do the requests need to be asynchronous.

来自 Introducing JSON :

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.

https://stackoverflow.com/questions/939211/

相关文章:

javascript - 将 JSON 对象推送到 localStorage 中的数组

ruby-on-rails - JBuilder中未定义的局部变量或方法 `json'

json - SQL Server OPENJSON 读取嵌套的 json

json - 使用 jq 就地修改 json 中的键值

python - IPython Notebook 中漂亮的 JSON 格式

java - 如何测试 JSONObject 是否为空或不存在

python - 将 JSON 文件读入 Spark 时出现 _corrupt_record 错误

android - 如何在 Android 中解析 JSON 对象

javascript - 如何从对象中删除所有 null 和空字符串值?

json - 调用 Web API 2 端点时出现 HTTP 415 不支持的媒体类型错误