I would like to run a javascript file (function unknown) once in a while. Perhaps on some click event. How can I do this?
I want to use this for a twitter update with the following code:
<script type="text/javascript" src="http://twitter.com/statuses/user_timeline/username.json?callback=twitterCallback2&count=1"></script>
So this src has to be called once in a while, so I can do a live update, instead of just having a static feed.
Thanks in advance.
You may want to do script-tag injection:
Which you can then invoke as follows:
injectFile('http://twitter.com/statuses/...js');. You’re free to call that from anonclickhandler, or periodically usingsetTimeout()orsetInterval().It looks like the twitter script you’re including is a JSONP response, which is invoking the callback function
twitterCallback2(). You should have this defined in your code before loading the script.