How to get a current value from jQuery's ajaxSetup

前端 未结 3 425
自闭症患者
自闭症患者 2021-01-17 08:50

I have a page that, at the user\'s request, opens a dialog box and loads an external file into it using jQuery\'s load() method.

The external file contains links to

相关标签:
3条回答
  • 2021-01-17 08:55

    you can do this:

    $.ajaxSetup()['cache']
    
    0 讨论(0)
  • 2021-01-17 09:05
    // Save current global ajax setup
    $.cachedAjaxSetup = $.extend(true, {}, $.ajaxSetup());
    
    // change global ajax setup
    $.ajaxSetup({
      headers : { "Authorization": 123 }
    });
    
    // revert back to saved ajax setup
    $.ajaxSetup( $.cachedAjaxSetup );
    

    The (annoying) problem is, the object will be merged, so for the above example, the headers setting will remain because it didn't exist on the original object.

    You can overcome this if you know which properties were added, cache them and remove them manually like so delete $.ajaxSettings.headers and then add them back when you need that setting again. dirty, but it works..

    0 讨论(0)
  • 2021-01-17 09:18

    You could use this:

    $.ajaxSettings['cache']
    
    0 讨论(0)
提交回复
热议问题