What are the common ways to request back-end interface data from the front end?

I only know ajax,. Are there any other common methods, and where is the specific usage scenario?

Feb.08,2022

form forms, Axios, and websoket.
form forms usually do registration and login or form submission information, but usually in order to do more processing, individuals are used to writing into the code to deal with it.
xios is similar to the usual use of ajax, and is essentially an encapsulation of native XHR, except that it is the implementation version of Promise, conforms to the latest ES specification, and has more features extended
websoket can be regarded as long links, suitable for instant messaging, or scenarios in which the front end can actively receive data instructions sent by the backend for feedback.

axios : Axios is a promise-based HTTP library that can be used in browsers and node.js.

create XMLHttpRequests from browser
create http request from node.js
support Promise API
intercept request and response
convert request and response data
cancel request
automatically convert JSON data
client supports defense XSRF
Chinese document address: https://www.kancloud.cn/yunye.

HTML5 WebSocket : a protocol for full-duplex communication over a single TCP connection

WebSocket makes it easier to exchange data between the client and the server, allowing the server to actively push data to the client. In WebSocket API, only one handshake is needed between the browser and the server, and a persistent connection can be directly created between the browser and the server for two-way data transmission.
in WebSocket API, the browser and the server only need to shake hands, and then a fast channel is formed between the browser and the server. Data can be transmitted to each other directly between the two.
http://www.runoob.com/html/ht.

if you don't consider the exotic ie:
send method of xhr object, a substitute for
xhr, api's more friendly, promise-based fetch method,
dynamically create scripts, jsonp,
bypassing cross-domain problems can maintain long links and transmit data in both directions. It is often used for websocket in real-time interactive scenarios

.
Menu