Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

http request in js

//Using the javascript Fetch API 
//References: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch

fetch('http://localhost:8080/test')
  .then((response) => response.json())
  .then((data) => console.log(data));
Comment

http get request js

function httpGetAsync(theUrl, callback) {
    var xmlHttp = new XMLHttpRequest();
    xmlHttp.onreadystatechange = function() { 
        if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
            callback(xmlHttp.responseText);
    }
    xmlHttp.open("GET", theUrl, true); // true for asynchronous 
    xmlHttp.send(null);
}

httpGetAsync("/api/v1/items", (res)=>{
  	// page content is in variable "res"
});
Comment

http request javascript

const requests = new XMLHTTPRequest();

requests.open('METHOD', url)
requests.send()

requests.onload = () => {
 if (requests.status == 200) {
   console.log('ok')
 } else {
 console.log('didnt work')
 }
}
Comment

http request javascript

function httpGetAsync(url, callback) {
  var xmlHttp = new XMLHttpRequest();
  xmlHttp.onreadystatechange = function() { 
    if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
      callback(xmlHttp.responseText);
  }
  xmlHttp.open("GET", url, true); // true for asynchronous 
  xmlHttp.send(null);
}
Comment

Javascript make HTTP request

const xhr = new XMLHttpRequest();
JavaScriptCopy
Comment

Javascript make HTTP request

xhr.open(Method, URL[, Async]);
JavaScriptCopy
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript regex insert string 
Javascript :: how to access ::after Pseudo-Elements from javascript 
Javascript :: javascript this Inside Object Method 
Javascript :: image react native base64 
Javascript :: remove element javascript 
Javascript :: js index to index 
Javascript :: data attribute hide & show function syntax in jquery 
Javascript :: sequelize migration enum 
Javascript :: The toString() Method 
Javascript :: javascript set() method 
Javascript :: how to disable option after select using jquery 
Javascript :: redux action creators 
Javascript :: nodejs: router by use express and path package 
Javascript :: vue v-for loop array 
Javascript :: is date 1 day ago javascript 
Javascript :: query selector element with class and parent class 
Javascript :: window frames js 
Javascript :: nvm use a particular version 
Javascript :: todo list javascript 
Javascript :: shorthand arrow function 
Javascript :: update property of object in array javascript 
Javascript :: table like another component in react native 
Javascript :: react native image picker 
Javascript :: Find the count of a letter in a string 
Javascript :: string in js 
Javascript :: java script alerts 
Javascript :: Modify String with Uppercase 
Javascript :: JS how to access a class propert 
Javascript :: how to make a bigint in javascript 
Javascript :: for ... of ... 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =