jQuery keeps putting a cache buster in my CDN scripts?

后端 未结 1 1974
广开言路
广开言路 2021-01-14 05:58

I have a script that uses $.get( ... ) to pull a piece of HTML from my server, and render it inside a

with $.html. Sometim
相关标签:
1条回答
  • 2021-01-14 06:33

    When jQuery sees a <script src="URL"> tag in the HTML, it uses $.getScript() internally to load the script. By default, this sends a cachebuster, but you can override the default AJAX options by calling $.ajaxSetup().

    $(document).ready(function () {
        $.ajaxSetup({
            cache: true
        });
        var x = '<script src="https://d9zdvmiwibsh5.cloudfront.net/js/json.js">';
        $('#test').html(x);
    });
    

    DEMO

    0 讨论(0)
提交回复
热议问题