Reputation: 769
In jQuery I can set ajax default parameters with ajaxSetup like:
$.ajaxSetup({'async': false});
Is it possible to read them? So that for the example above I knew if async is currently set to false
or true
?
Upvotes: 1
Views: 124
Reputation: 336
Well you can do this:
var myAjaxSetup= $.ajaxSetup({'async': false});
Then
if(myAjaxSetup.async){ // dO SOME }
But this is only for simple evaluation, if you try to do over $.ajax() call, the "async" param doesn't exist.
var someNice = $.ajax({'async': false});
console.log(someNice.async) //undefined
Upvotes: 1
Reputation: 59386
You can do this $.ajaxSetup()['cache']
, but please don't. The use of ajaxSetup
is not encouraged, this may lead to misbehavior as your application grows bigger, because each Ajax call would depend on the state of your application, which leads to unpredictability.
If you really need default options for ajax, you could try using $.extend
to merge your current options with the default options returned by some method call.. maybe some object injected through requireJs
maybe. At least you can debug and see which params are being passed to your request.
Upvotes: 2