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 :: angular build production 
Javascript :: how to convert seaconds into hh:mm:ss in javascript 
Javascript :: discord.js start code 
Javascript :: check if all values in array are negative javascript 
Javascript :: types of loops in javascript 
Javascript :: reset form input react 
Javascript :: js fetch api 
Javascript :: js increment and decrement function for cart 
Javascript :: jquery datatime 
Javascript :: javascript whitespace strip 
Javascript :: get the whole value of a number javascript 
Javascript :: mongoose countdocuments 
Javascript :: js string methods 
Javascript :: send csrf token ajax laravel 
Javascript :: how to make a popup in javascript -html 
Javascript :: js get json object keys 
Javascript :: Converting file to base64 on Javascript client side 
Javascript :: base64 encoded data to object in javascript 
Javascript :: react testing library for hooks 
Javascript :: using html forms to define javascript variables 
Javascript :: open in a new tab react 
Javascript :: link in directive angularjs 
Javascript :: read multiple parameters in url in js 
Javascript :: how to remove property of object in javascript without delete 
Javascript :: how to merge two object arrays in javascript 
Javascript :: change text in html with javascript 
Javascript :: install react bootstrap 
Javascript :: convert a string into an integer 
Javascript :: ejs include with variable 
Javascript :: npm font awesome 5 angular 7 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =