Forum Moderators: open
on my page i call a javascript file called code.php as
<script src="code.php"></script>
the content of this code.php produces a document.write("") line that displays on my page. However, as the document.write writes text i wanted to know how i can use a javascript to refresh <script src="code.php"> every 20seconds or so. At the moment i am using a normal meta refresh tag which i dont like.
many thanx in advanced.
setTimeout [pageresource.com]
Location object [devguru.com]
basically what i am trying to do is as follows:
i have a file called code.php when this code.php is called via a browser it displays the following:
<!--
document.write("Active: <b>25</b>")
//-->
the value 25 dynamically changes using the code of the php file.
I basically call the code.php file into my html file as follows:
<script src="code.php"></script>
this results to it display the following:
Active: <b>25</b>
But what i am trying to do is get this refreshed every 20 seconds. at the moment i have to refresh the whole page just to refresh this javascript file. I wanted to know if there was anyway to just refresh the file called
I don't think there's simple solution from then on though. One way (with 2 methods) boils it down to the usual 'inner-browing' problem of partially updating content without a full page refresh. With that you can use an invisible iframe, which gets tricky, or use an HTTP request.
I don't think you can go changing the src property of the script tag. If you could, you could perhaps keep calling it with a random, dummy query string to fool caching. The script would innerHTML your new content into a document element.
You could try createElement('script'), but you'd fill your document up with script tags after a while.