Hello!

I need to store in object variables xml data contained in different
xml files. The code i came up with does not seem to function properly.
Can you tell me what i'm doing wrong?

$(document).ready(function()
    {
        // To preload more files, add them to the filesToLoad array.
        var filesToLoad = [{ instance: 'ds_projects_XML', file:
'projects/datascapes.xml' }, { instance: 'ds_people_XML', file:
'people/datascapes.xml'}];

        for (var i = 0; i < filesToLoad.length; i++)
        {
            var $file = filesToLoad[i].file;
            var $instance = filesToLoad[i].instance;
            $.get($file, {}, function(xmlData, strStatus)
            {
                if (strStatus == 'success')
                {
                    // $.log('M2.START: success loading file : ' +
$file);
                    eval($instance + ' = $(xmlData)');
                    if (i === (filesToLoad.length - 1))
                    {
                       $.log('finished loading!');
                    }
                }
                else
                {
                    $.log('error loading file : ' + $file + ' error: '
+ strStatus);
                }
            });
        }
});

Reply via email to