XMLHttpRequest datos de solicitud y solicitud de escritura de datos de solicitud

Código de muestra simple para XMLHttpRequest para enviar una solicitud Ajax:

let xhr;
if (window.XMLHttpRequest) {
    
    
   xhr = new XMLHttpRequest();
} else {
    
    
    xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
xhr.responseType = "arraybuffer"; 
xhr.open("GET", " /getByIds?ids="+ this.rgbImagePath, true);
xhr.onload = function () {
    
    
    if (xhr.readyState == 4 && xhr.status == 200) {
    
    
       //xhr.response为请求到的数据
       console.log('xhr.response:',xhr.response);
     }
 };
xhr.send();

Código de ejemplo simple de Solicitud de solicitud:

request({
    
    
    url:"/getByIds?ids="+this.rgbImagePath,
    methods:"get",
   }).then((res)=>{
    
    
     this.imageArray = res;
   })

Escritura de cadena de consulta:

// Dirección URL sin parámetros
".../.../getByIds"
// Dirección URL con un parámetro
".../.../getByIds?ids"+this.id
// Dirección URL con dos parámetros
". ../.../ getByIds?ids"+este.id+"&name="+este.nombre

Supongo que te gusta

Origin blog.csdn.net/YG_zhh/article/details/126946688
Recomendado
Clasificación