/    Sign up×
Community /Pin to ProfileBookmark

Refresh an external javascript file from the server at intervals?

Hi guys,

I have a webpage in which certain content will be called from a javascript file.

I will be linking to the file as follows:

[code]<script type=”text/javascript” src=”js.js”></script>[/code]

The js.js file will be updated by an admin in my office.

Is it possible to have the js.js file called from the server periodically – say every 1800 seconds (to update the webpage without interrupting the user)?

Also can there be a link to manually call the js.js file as well, in case a user doesn’t want to wait 1800 seconds for the next update?

I’m aware of the meta refresh tag but this would interrupt the user and erase text from the form fields that they need to use throughout the day.

Your help is greatly appreciated.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@George88Sep 23.2012 — I'm assuming you want a particular function in "js.js" to be called every 1,800 seconds? If so, you can simply include the JavaScript file on the page in question like you already have done, then use the setInterval function to call the given function each 1800 seconds.

<i>
</i>&lt;script type="text/javascript" src="js.js"&gt;&lt;/script&gt;

&lt;script type="text/javascript"&gt;

var refresh = setInterval
(
function()
{
your_function();
your_other_function();
}, 1800000 // milliseconds.
);

&lt;/script&gt;


Is that what you were looking for? If not, post more info.
Copy linkTweet thisAlerts:
@ZABISep 24.2012 — You can use AJAX to load external content on demand or regular intervals without reloading the page.

you can also try jQuery getScript function http://api.jquery.com/jQuery.getScript/
×

Success!

Help @W8_4me spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...