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