minimum generation tree -template scar

2023-01-12   ES  

1. What is AJAX

Ajax (Asynchronous Javascript and XML) asynchronous JavaScript and XML asynchronous
Ajax is a set of APIs provided by the browser
can call the API and server provided by AJAX through JavaScript for interaction
AJAX’s core object is XMLHTTPREQUEST

2. Application scenario

Get data on demand
Baidu map loading, message comment and other functions
User data verification
When registering, verify whether the user name or mailing is registered
automatic update page content
Email reminder, message reminder
Raise user experience, experienceless refresh experience

3. axios

Features:

HTTP library based on Promise
Support all PROMISE all APIs
is higher security, client supports defense XSRF
can be converted to request data and response data, and automatically converted into the JSON type data to the content of the response
can intercept requests and responses

axios.get(’/user’,{

params: {

id: 123456
}
})
.then(function (res){

console.log(res)
})
.catch(function(err){

console.log(err)
})

4. Fetch API

fetch response results The data format is:

res.Text () Get the form data of the string
res.json () directly get JSON data

fetch(‘http://localhost:3000/data’)
.then(res=>{

return res.json();
}).then(res=>{

console.log(res.username)
})

fetch API advantages:

Synthetic, more semantic
Based on standard PROMISE implementation, support Async, AWAIT

5.AXIOS, FETCH, AJAX difference 

 The main difference between

is Axios, fetch requests the Promise object API, AJAX can only use the callback function
AXIOS supports request/response interception, you can automatically convert JSON data
fetch provides a rich API, more underlying

source

Related Posts

The BIOS setting hard disk of each brand notebook is compatible mode (IDE) method (transfer)

Protective measures for vulnerabilities of Android application

Java Multi -threaded parallel computing matrix multiplication (star notes)

[Play to Pointpillars] Pillarscatter operation

minimum generation tree -template scar

Random Posts

mysql database security backup

Business operation and maintenance actual combat: How does Tencent optimize the APP user experience?

Intent to pass data PARCLABLE, Serializable, Bundle detailed usage

[Basic Tutorial] BP neural network

Use myBatis-Generator to automatically generate code