Get started with ajaxrequest.js CDN

MIT licensed

AJAXRequest.js: library for making async HTTP requests with XMLHttpObject.

Tags:
  • util
  • ajax
  • client
  • browser

Stable version

Copied!

How to start using ajaxrequest.js CDN


// Create a new AJAXRequest object
const xhr = new AJAXRequest();

// Set the request method, URL, and optional headers
xhr.open('GET', 'https://jsonplaceholder.typicode.com/todos/1', true);
xhr.setRequestHeader('Content-type', 'application/json');

// Define a function to handle the response
xhr.onload = function() {
  if (xhr.status === 200) {
    // Parse the response as JSON and log the data to the console
    const data = JSON.parse(xhr.responseText);
    console.log(data);
  } else {
    console.log('Error:', xhr.statusText);
  }
};

// Send the request
xhr.send();
Copied!
Copied!

All versions