Hey guys,

i'm fairly new to ajax, and today discovered that javascript files won't fire within an ajax loader.

my problem: i've built a web application using a mixture of javascript, ajax, and html. however this is designed to go on a page that already takes a little time to load.
So i thought' id do a:

<body onload="ajaxLoader('file.php','holder')" >


function ajaxLoader(url,id) { 
               if (document.getElementById) { 
                    var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); 
               if (x) { 
                    x.onreadystatechange = function() { 
                         if (x.readyState == 4 && x.status == 200) { 
                              el = document.getElementById(id); 
                              el.innerHTML = x.responseText; 
                    x.open("GET", url, true); 

this works fine it loads the php file but doesnt import the javascript files.

i've got 3 javascript files that i need to use within the 'mini app' how do i load these javascript files within the application?

any help greatly recieved


9 Years
Discussion Span
Last Post by ejosiah

I don't see the point in loading files with the onload event; thats not the point of ajax but anywayz your javascript files load as string objects so wat you want to do is the use the eval function to execute the script


The reason i want it loading on body is because the app is not the important data, i dont want it to start loading until the rest of the page has loaded.

So i should be using Object.eval() to execute the 3 extra javascript files or using the eval on the ajax div at the start?

thanks for getting back to me :)


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.