Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

ajax mdn

<button id="ajaxButton" type="button">Make a request</button>

<script>
(function() {
  var httpRequest;
  document.getElementById("ajaxButton").addEventListener('click', makeRequest);

  function makeRequest() {
    httpRequest = new XMLHttpRequest();

    if (!httpRequest) {
      alert('Giving up :( Cannot create an XMLHTTP instance');
      return false;
    }
    httpRequest.onreadystatechange = alertContents;
    httpRequest.open('GET', 'test.html');
    httpRequest.send();
  }

  function alertContents() {
    if (httpRequest.readyState === XMLHttpRequest.DONE) {
      if (httpRequest.status === 200) {
        alert(httpRequest.responseText);
      } else {
        alert('There was a problem with the request.');
      }
    }
  }
})();
</script>
Comment

ajax mdn

adawdawdawgrg
Comment

PREVIOUS NEXT
Code Example
Javascript :: Access child elements of a main element js 
Javascript :: js array to string 
Javascript :: javascript how to get subarray 
Javascript :: compare mongoose id 
Javascript :: javascript add element to array 
Javascript :: check for string anagram javascript 
Javascript :: find common characters in two strings javascript 
Javascript :: Javascript How to push a key value pair into a nested object array 
Javascript :: cards in react native 
Javascript :: js countdown 
Javascript :: http delete angular 
Javascript :: jquery 
Javascript :: remove element from array 
Javascript :: jsx style styling 
Javascript :: convert inches to feet javascript 
Javascript :: change js 
Javascript :: loop through array react native 
Javascript :: join array 
Javascript :: javascript on selected 
Javascript :: discord.js timeout 
Javascript :: Calculator Function JS Javascript 
Javascript :: clean collection mongoose 
Javascript :: adding function to objects js 
Javascript :: sequelize mariadb example 
Javascript :: javascript bitwise operators 
Javascript :: node ssh 
Javascript :: ran ctrl c and npm server is still running 
Javascript :: video mute and unmute 
Javascript :: how to concat nested array in javascript 
Javascript :: remove duplicate array es6 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =