XMLHttpRequest Methods


XMLHttpRequest methods are used to control how requests are sent to the server.

Methods define what action the browser should perform during AJAX communication.

The open method prepares the request.

It defines the request type, server file, and communication mode.

The send method sends the request to the server.

Without calling send, the request will never reach the server.

The setRequestHeader method is used when sending data using POST.

It tells the server what type of data is being sent.

The abort method stops an AJAX request before it is completed.

This is useful when a request is no longer needed.

The getResponseHeader method retrieves a specific response header from the server.

The getAllResponseHeaders method returns all response headers sent by the server.

These methods work together to control the full AJAX request lifecycle.

Understanding these methods helps you write clean, controlled, and professional AJAX code.