How do I send XMLHttpRequest with JavaScript?

To send an XMLHttpRequest with JavaScript, you need to create an XMLHttpRequest object, open the URL, and send the request. After the request has been made, the response body can be retrieved and processed using the xhr.response attribute of the XMLHttpRequest object. Additional HTTP headers can be passed to the server using the xhr.setRequestHeader() method. In this JavaScript XMLHttpRequest Request Example, we use the XMLHttpRequest object to send an asynchronous request to the ReqBin echo URL. Click Execute to run JavaScript XMLHttpRequest Example online and see the result.
Loading...