“JavaScript HowTo Get Xhr” Respostas de código

JavaScript HowTo Get Xhr

function httpGet(theUrl)
{
    var xmlHttp = new XMLHttpRequest();
    xmlHttp.open( "GET", theUrl, false ); // false for synchronous request
    xmlHttp.send( null );
    return xmlHttp.responseText;
}
Jittery Jackal

XHR solicita javascript

window.onload = function(){
    var request = new XMLHttpRequest();
    var params = "UID=CORS&name=CORS";

    request.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
            console.log(this.responseText);
        }
    };

    request.open('POST', 'https://www.example.com/api/createUser', true);
    request.setRequestHeader('api-key', 'your-api-key');
    request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    request.send(params);
}
Gorgeous Grasshopper

Respostas semelhantes a “JavaScript HowTo Get Xhr”

Perguntas semelhantes a “JavaScript HowTo Get Xhr”

Mais respostas relacionadas para “JavaScript HowTo Get Xhr” em JavaScript

Procure respostas de código populares por idioma

Procurar outros idiomas de código