...

View Full Version : Is there any way to re-retrieve that JavaScript file, from the server



jroehl
07-16-2010, 09:33 PM
So, this is my last problem. If I can nail this, then the website will be completely AJAX driven, and will be spectacular.

It took me a while to figure out just how to ask the question. lol

Now it is really simple.

1) When I hit the button, in the simplified example below, the website sends a code to the server.
2) The server then re-writes the "xyz.js" JavaScript file with a new array of values.

Is there any way to re-retrieve that JavaScript file, from the server to make it the current "xyz.js" rather than the old one that loaded on the client originally.

I can get a new XML data file and re-submit that to the website, but how do I re-retrieve the new JavaScript code?



<html>
<head>
<script src="xyz.js" type="text/javascript"></script>
</head>
<body>
<button onclick="onload();">Change</button>
</body>
</html>

RandomUser531
07-18-2010, 12:22 AM
Your function should not be called 'onload' as this could conflict with any onload handler installed.

<script id='scriptElem' src="xyz.js" type="text/javascript"></script>

You could try
var se = document.getElementById('scriptElem');

se.src='xyz.js?r=' + new Date().getTime();

se.parentNode.replaceChild( se, se );



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum