-1

I need to add some header details to one specific ajax request that one of the third party control will make. The third party control allows me to set the URL but it does not allow me to add header information to the request.

So far I am able to add header to every ajax request by this code:

 $( document ).ajaxSend(function( event, jqxhr, settings ) {
    jqxhr.setRequestHeader(key, value);
  });

Is there any way to add this header only for specific URL ?

SharpCoder
  • 18,279
  • 43
  • 153
  • 249
  • possible duplicate of [How can I add a custom HTTP header to ajax request with js or jQuery?](http://stackoverflow.com/questions/7686827/how-can-i-add-a-custom-http-header-to-ajax-request-with-js-or-jquery) – Hacketo Jun 23 '15 at 09:21

1 Answers1

0

This is what you are looking for I believe.

$( document ).ajaxSend(function( event, jqxhr, settings ) {
  if ( settings.url == "someURL" ) {
    jqxhr.setRequestHeader(key,value);
  }
});
Ankit Kathiriya
  • 1,221
  • 10
  • 17
Rob Schmuecker
  • 8,934
  • 2
  • 18
  • 34