Hello,
I am using prototype to load external js file (actually it is php file) dynamically. Like this:
function UpdateJS(file)
{
var url = 'main_js.php?file='+file;
var myAjax = new Ajax.Request( url, {method: 'get', onComplete: showResponseHeader} );
}
function showResponseHeader (originalRequest)
{
$('jscode').innerHTML = originalRequest.responseText;
}
Container "jscode" is defined like this:
<script type="text/javascript" id="jscode"></script>
And it works! But if some different file is called, all the functions from previous one are preserved. And I don't want that. Anybody knows how to "unload" first js file when second one is called?
(I also tried using Ajax.Updater function but the result is the same.)
Update: It turns out that there is bigger problem: it only loads if function "UpdateJS" is in window.onload that is why it doesn't load anything else after that. So prototypes update it's maybe not such a good way for this...