Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2010
    Thanked 0 Times in 0 Posts

    Is there any way to re-retrieve that JavaScript file, from the server

    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?

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

  • #2
    New Coder
    Join Date
    Jul 2010
    Thanked 21 Times in 21 Posts
    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 );


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts