javascript - jQuery $.ajaxSetup headers applies to all ajaxRequests even when overwritten -
i have in below parameters ajax calls in <head>
of document. (i need ios ajax bug @ https://stackoverflow.com/a/12856562/627473
$.ajaxsetup ({ cache: false, headers: { "cache-control": "no-cache" } });
i have service communicating denies cache-control header in way.
so tried below before making ajax request.
$.ajaxsetup ({ cache: true, headers: { 'invoke-control': 'emvx' } });
the above request still includes "cache-control": "no-cache" header. requirement of service making request prohibits cache-control header being in request (even if blank or has cache value.
my request includes invoke-control (which want); not want cache-control show @ all.
i tried specifying headers in $.post request , still merges headers $.ajaxsetup.
i using jquery v1.11.1. there workaround?
there no way can it.
according jquery documentation of jquery.ajaxsetup,
the settings specified here affect all calls
$.ajax
or ajax-based derivatives such$.get()
. can cause undesirable behaviour since other callers (for example, plugins) may expecting normal default settings. reason recommend against using api. instead, set options explicitly in call or define simple plugin so.
it indicates append header calls.
to prevent this,
you can following
instead of using $.ajaxsetup
, try use
$.ajax({ beforesend: function(){ jqxhr.setrequestheader("cache-control","no-cache"); }
to specific requests want
Comments
Post a Comment