Leran JavaScripts

Get started with JS Ajax

AJAX Helps to:

Read data from a server - after the page has loaded Update a web page without reloading the page Send data to a web server - in the background


AJAX Example Explained

What is AJAX?
AJAX = Asynchronous JavaScript And XML.
AJAX is not a programming language.
AJAX just uses a combination of:
A browser built-in XMLHttpRequest object (to request data from a web server)
JavaScript and HTML DOM (to display or use the data)

Function loadData()
          
function loadData() {
  const xhttp = new XMLHttpRequest();
  xhttp.onload = function() {
    //select the div where data should be displayed
    document.getElementById("demo").innerHTML = this.responseText;
    }
  }