title: Why do we write onload() function before we write send() in XMLHttpRequest
body: <p>I am new to XMLHttpRequest. I dont understand why do we write onload() function before send() function. onload() function process the response what we receive and send() function sends a request to server. So onload() has to be written after send() function as per my understanding. Can somebody help to understand this.</p>
  
  <pre><code>var xmlhttp = new XMLHttpRequest(),
    method = 'GET',
    url = 'https://developer.mozilla.org/';
  
  xmlhttp.open(method, url, true);
  xmlhttp.onload = function () {
    // Do something with the retrieved data
  };
  xmlhttp.send();
  </code></pre>