What is the difference between XMLHttpRequest
and AJAX
? Can anybody provide some examples to know the difference in terms of functionality and performance?
-
1https://stackoverflow.com/questions/4657287/what-is-the-difference-between-xmlhttprequest-jquery-ajax-jquery-post-jquery it has been answered – Mr Hery Dec 30 '17 at 04:27
2 Answers
XMLHttpRequest can be used to retrieve any type of data, not just XML, and it supports protocols other than HTTP including file and ftp.
var XMLHttpRequest = new XMLHttpRequest();
XMLHttpRequest.onreadystatechange = function() {
if (XMLHttpRequest.readyState == XMLHttpRequest.DONE) {
console.log(XMLHttpRequest.responseText);
}
}
XMLHttpRequest.open('GET', 'http://google.com', true);
XMLHttpRequest.send(null);
AJAX stands for Asynchronous JavaScript And XML. it is the use of the XMLHttpRequest to communicate with servers.
It can send and receive information in various formats, including JSON, XML, HTML, and text files.
var request = $.ajax({
type: 'GET',
url: "http://google.com",
async: true,
success: function() {
console.log('sucess');
}
});

- 4,097
- 3
- 23
- 36
I already know a answer was submitted previously.
(Asynchronous JavaScript + XML)
Is a group of interrelated client- and server-side development technologies that allows parts of a webpage to be updated without having to reload the entire page think of sites like YouTube, Google Maps, Gmail, and tabs within Facebook. It changed usability and the speed of web applications with its innovative concept: asynchronously exchanging small amounts of data with the server behind the scenes, without affecting the rest of the page. XMLHttpRequest is just a implementation of ajax, The XMLHttpRequest object is used to exchange data with a server.

- 3,813
- 2
- 18
- 25
-
Bare in mind, it is based on REST verbs, Get,Post etc, therefore it can upload and send multipart data, files with ftp you name it. – Remario Dec 30 '17 at 04:58
-
it means simple xhr and ajax request both are same in functionality and the only difference is cross browser compatibility? – Neha Dec 30 '17 at 06:28
-
1there is no difference, ajax is just a definition , xhr is a implementation, – Remario Dec 30 '17 at 15:21