javascript - Is there another way to disable cache when fetching script? -


i use fetch script;

$.getscript("http://www.example.org/"); 

however, dont want cached. means if use getscript again, script should fetch again.

this 1 works in theory;

$.getscript("http://www.example.org/?" + math.random()); 

but in practically, it's not. because "?" disabled on remote site url, question is, there otherway tell browser not cache ?

recreate function needs:

(function () {     $.getscript = function(url, callback) {         $.ajax({                 type: "get",                 url: url,                 success: callback,                 datatype: "script",                 cache: false         });     }; })(); 

now won't cache anymore when call function like

$.getscript('script.js', function() {     // non cached script.js }); 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -