javascript - Is there any way to remove Ajax headers set by setRequestHeader()? -


i’m writing js script lives within system adding custom xid header ajax requests via jqxhr.setrequestheader() in function registered jquery.ajaxprefilter().

in script, need make ajax request third party site, access-control-allow-headers not set allow custom xid header.

it seems have 3 options:

  1. find way remove xid header in $.ajax()’s beforesend function, have confirmed gets called after ajaxprefilter() function.
  2. forgo using $.ajax() entirely , write ajax stuff myself.
  3. have $.ajax() point system’s backend accept custom xid header, , perform request third party site via curl.

option #1 preferred, if there’s simple way it, since cleanest , fastest route. can’t figure out how.

i have tried overriding this, didn’t work:

beforesend: function(jqxhr, settings) {     jqxhr.setrequestheader('custom-xid-header', null); } 

any ideas?

$.ajaxsetup({     beforesend: function(jqxhr, settings) {         jqxhr.setrequestheader('custom-xid-header', null);     } }) 

see http://api.jquery.com/jquery.ajaxsetup/


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -