function include (jsFile) {
new Ajax.Request(jsFile, {
method: 'get',
asynchronous : false,
onSuccess: function(transport) {
// Evaluate the javascript
eval(transport.responseText);
},
onFailure : function() {
alert("Failure including file: " + jsFile);
}
});
}
hello.js
sayhello = function () {
alert("I'm saying hello!");
}
include('hello.js');
sayhello();