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 :: remove duplicate strings from array javascript 
Javascript :: if string javascript 
Javascript :: react allow only numbers in input 
Javascript :: node js favicon.ico 
Javascript :: add attribute selected jquery 
Javascript :: check class exist in element by parent id in jquery 
Javascript :: javascript show 2 decimal places 
Javascript :: how to check if input file is empty in jquery 
Javascript :: datatables cdn file 
Javascript :: square all numbers in array javascript 
Javascript :: remove first 3 characters from string javascript 
Javascript :: javascript moeda reais 
Javascript :: drupal twig node alias 
Javascript :: javascript change color for class name 
Javascript :: submit form without loading page 
Javascript :: randome words api 
Javascript :: js validate date object 
Javascript :: detect button click jquery 
Javascript :: Iterating through an Object 
Javascript :: convert 24 hours to 12 hours javascript 
Javascript :: como deletar node js linux 
Javascript :: javascript middle of array 
Javascript :: get the domain name in javascript 
Javascript :: mac install jmeter 
Javascript :: javascript filter array of objects by id 
Javascript :: function click anywhere javascript 
Javascript :: angular 8 how to iterate json object in view 
Javascript :: javascript remove last character 
Javascript :: javascript get date without time 
Javascript :: javascript Count the occurrences of a value in an array 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =