title: jquery ajax difference between header and beforesend
body: <p>I was reading the doc on how to set headers and there are apparently two ways one is with beforesend xhr and the other is just passing a object header with values. What's the difference between them?</p>
  
  <p><strong><em>beforeSend</em></strong></p>
  
  <pre><code>$.ajax({
      cache: false,
      type: "GET",
      url: "/",
      beforeSend: function(xhr) {
          xhr.setRequestHeader('x-access-token', token);
      },
      success: function(data) {
           //Do something
      },
      error: function(data) {
          //Do something
      }
  });
  </code></pre>
  
  <p><strong><em>headers</em></strong></p>
  
  <pre><code>$.ajax({
      cache: false,
      type: "GET",
      url: "/",
      headers: {
          'x-access-token': token
      },
      success: function(data) {
          //Do something
      },
      error: function(data) {
          //Do something
      }
  });
  </code></pre>