Multiple choice technology architecture

What’s the function of setRequestHeader() method in XMLHttpRequest Object ?

  1. Sends an HTTP request to the server.

  2. Returns all of the HTTP headers.

  3. Sets the name and value of an HTTP Header.

  4. Opens a request to the server.

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The setRequestHeader() method sets a custom HTTP header (name-value pair) that will be sent with the request. It must be called AFTER open() but BEFORE send(). Option A describes send(), Option B describes getAllResponseHeaders(), and Option D describes open().