简体   繁体   English

AJAX 请求、常规 HTTP 调用和 REST ZDB974238714CA8DE634A7CE1DF08 之间有什么区别?

[英]what is difference between AJAX request, regular HTTP call and REST API?

I am really confused regarding these terms.我对这些术语感到非常困惑。 According to my understanding, an ajax request can only fetch your data but a REST API can add data to the database.Can someone please help据我了解,ajax 请求只能获取您的数据,但 REST API 可以将数据添加到数据库中。有人可以帮忙

AJAX stands for "Asynchronous JavaScript and XML", it is just a term. AJAX代表“异步 JavaScript 和 XML”,它只是一个术语。 It uses HTTP to make requests to a web server.它使用 HTTP 向 web 服务器发出请求。

An AJAX request is not just used to fetch data, it can be used to make any request be it getting data, posting data or deleting data. AJAX 请求不仅用于获取数据,还可以用于发出任何请求,无论是获取数据、发布数据还是删除数据。 What it basically comes down to is making an asynchronous call and then using JavaScript to load the response data without needing to reload the page.它基本上归结为进行异步调用,然后使用 JavaScript 加载响应数据,而无需重新加载页面。 Read more here AJAX - MDN在此处阅读更多内容 AJAX - MDN

HTTP stands for "Hypertext Transfer Protocol". HTTP代表“超文本传输协议”。

It is a protocol for transmitting hypermedia such as HTML trough the web.它是一种通过 web 传输 HTML 等超媒体的协议。 Basically a client may open a request and the server will respond accordingly.基本上,客户端可能会打开一个请求,服务器会做出相应的响应。 Read more here - HTTP - MDN在此处阅读更多信息 - HTTP - MDN

An API is an "Application Programming Interface" it is a way for computers to talk to each other if you think about it like that, or for you as a developer to interact with a technology someone as built. API是一种“应用程序编程接口”,如果您这样想,它是计算机相互交谈的一种方式,或者您作为开发人员可以与某人构建的技术进行交互。

REST stands for "Representational State Transfer" and is an architectural style that Roy Fielding came up with on his 2000 dissertation Architectural Styles and the Design of Network-based Software Architectures . REST代表“Representational State Transfer”,是 Roy Fielding 在他 2000 年的论文Architectural Z4C1C7D945FCD04D68BD3B3F1D9 Architecture 和 Design of Network 中提出的一种架构风格。

So a REST API is just a way to build an API that follows a set of "rules", for example, using hypermedia, being stateless, and using correct status codes.因此, REST API只是构建遵循一组“规则”的 API 的一种方式,例如,使用超媒体、无状态和使用正确的状态代码。 There is a lot to learn about REST to really get it right and it is a complex topic to discuss in a short answer, so I advise that you read more on this subject.有很多关于 REST 的知识要真正做到正确,这是一个需要简短回答的复杂话题,所以我建议您阅读更多关于这个主题的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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