Reputation: 3333
Does anyone know, what an XMLHttpRequest
enables a web page to do, which cannot be done using a normal HttpRequest
?
Upvotes: 25
Views: 19982
Reputation: 449
while the standard HTTP request makes a 'synchronous' call and must wait for the response and makes a page-reload (you always get a new html-page to display) XMLHttpRequest may be used sync (not typical) and async (the better way) without a page-reload. you may ask for the response with javascript and the response is usually xml- or json-data that you may process with js and update parts of your page through the use of dom-methods that manipulate your document ... so you don't need an entire page reload because all of that is running in the 'background'
Upvotes: 2
Reputation: 499382
XMLHttpRequest
is a standard javascript object that allows you to make HTTP Requests from the browser in javascript.
HttpRequest
is a server side object that represents a request to the server.
In summary - one works in the browser, the other in the web server. They also have completely different roles. XMLHttpRequest
is for fetching web resources within the browser. HttpRequest
represents an incoming request.
Upvotes: 35