title: Is there any way to remove Ajax headers set by setRequestHeader()?
body: <p>I’m writing a JS script that lives within a system which is now adding a custom XID header to all Ajax requests via jqXHR.setRequestHeader() in a function registered with jQuery.ajaxPrefilter().</p>
  
  <p>In my script, I need to make an Ajax request to a third party site, whose Access-Control-Allow-Headers is not set up to allow this custom XID header.</p>
  
  <p>It seems I have 3 options:</p>
  
  <ol>
  <li>Find a way to remove that XID header in $.ajax()’s beforeSend function, which I have confirmed gets called after the ajaxPrefilter() function.</li>
  <li>Forgo using $.ajax() entirely and just write the Ajax stuff myself.</li>
  <li>Have $.ajax() point to the system’s backend which does accept the custom XID header, and perform the request to the third party site via cURL.</li>
  </ol>
  
  <p>Option #1 is preferred, if there’s a simple way to do it, since it will be the cleanest and fastest route. Just can’t figure out <em>how</em>.</p>
  
  <p>I have tried overriding it like this, but it didn’t work:</p>
  
  <pre><code>beforeSend: function(jqXHR, settings) {
      jqXHR.setRequestHeader('custom-xid-header', null);
  }
  </code></pre>
  
  <p>Any ideas?</p>