I need to Reload a specific js or css file by 2 second of interval. can it be done by jQuery?
I have tried to php_loop to execute this, but it is added the script one more time. Therefore I have tried to setinterval() but it didnt respond.
I need to Reload a specific js or css file by 2 second of interval. can it be done by jQuery?
I have tried to php_loop to execute this, but it is added the script one more time. Therefore I have tried to setinterval() but it didnt respond.
Reloading JavaScript or CSS should not be done without reloading the page.
I don't know what you are doing, but I would consider the "There is an update: Please refresh the page" alert box approach. (Like Gmail does for example)
If you still want to reload specific JavaScript or CSS, you can set the src
attribute of the script/style tags with another version number (file.js?v=randomnumber
).
Look at this answer for example (You still need to add the version part, as said before, to fix caching issues):
function reload_js(src) {
$('script[src="' + src + '"]').remove();
$('<script>').attr('src', src).appendTo('head');
}