Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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;
}
Comment

how to get xhr response in javascript

window.onload = function(){
    var request = new XMLHttpRequest();

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

    request.open('GET', 'https://restcountries.com/v2/all
');
    request.send();
}
 Run code snippetHide results
Comment

xhr request 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);
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: find element in array javascript 
Javascript :: angular keyup.enter 
Javascript :: createdAt expires mongoose 
Javascript :: Exceeded timeout of 5000 ms for a test. Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test." 
Javascript :: string length jquery 
Javascript :: check fro text input jquery 
Javascript :: how to loop object javascript 
Javascript :: javascript create script tag 
Javascript :: jquery get textarea text 
Javascript :: javascript empty cache and hard reload 
Javascript :: javascript store date in localstorage 
Javascript :: port 3000 is already in use nodemon app crashed 
Javascript :: react native use navigation outside component 
Javascript :: get current data and time in javascript 
Javascript :: jquery find id with string at end 
Javascript :: vuejs scrollBehavior 
Javascript :: get last in array javascript 
Javascript :: search content in js 
Javascript :: useHistory react testing 
Javascript :: react native width auto 
Javascript :: print odd numbers in an array in javascript 
Javascript :: math.rount 
Javascript :: remove console log in production react 
Javascript :: add border to view react native 
Javascript :: how to check what browser you are using javascript 
Javascript :: clear session storage on refresh 
Javascript :: deep copy object/array 
Javascript :: js import jquery 
Javascript :: how to delete node_modules file 
Javascript :: how to calculate distance between two points in javascript 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =