I'm currently trying to build an array from an Ajax request, creating
a new object for each item in the query. Here's the code:

        function ajaxMenu(whatTab){
                // retrieve the xml playlist
                $(document).ready(function(){
                        var id = 0;
                        var title = '';
                        // start menu
                        $("#layout_left_menu_float").empty();
                        $("#layout_left_menu_float").append("<ul>");
                    var playlist = new Array();

                        // load the xml and run a foreach loop
                        $.ajax({
                                type: "GET",
                                url: srcUrl+"playlist.xml",
                                dataType: "xml",
                                success: function(xml) {
                                                
$(xml).find('tab').each(function(){
                                                        findTab = 
$(this).find('id').text();
                                                        if(findTab != whatTab){
                                                                return true;
                                                        }
                                                        else {
                                                                var i = '0';
                                                                
$(this).find('item').each(function(index){
                                                                        // Grab 
all details
                                                                        title = 
$(this).find('title').text();
                                                                        type = 
$(this).find('type').text();
                                                                        file = 
$(this).find('file').text();
                                                                        qt = 
$(this).find('qt').text();
                                                                        wmv = 
$(this).find('wmv').text();
                                                                        content 
= $(this).find('content').text();
                                                                        
thumbnail = $(this).find('thumbnail').text();

                                                                        // 
Establish playlist item and add link
                                                                        
playlist[index]  = new Object();
                                                                        
playlist[index]['id']           =  index;
                                                                        
playlist[index]['title']        =  title;
                                                                        
playlist[index]['type']         =  type;
                                                                        
playlist[index]['file']         =  file;
                                                                        
playlist[index]['qt']           =  qt;
                                                                        
playlist[index]['wmv']          =  wmv;
                                                                        
playlist[index]['content']              =  content;
                                                                        
playlist[index]['thumbnail']    =  thumbnail;

                                                                        
$("#layout_left_menu_float").append(itemLink
(index,title,type));
                                                                });
                                                        return false;    // 
speed fix, ends once correct tab found
                                                        }
                                                }); // end each
                                } // end success
                        }); // end $.ajax
                        // end menu
                        $("#layout_left_menu_float").append("</ul>");
                }); // end document ready
        }


This function builds a menu from the items in a playlist, but at the
same time I want to store the data in a global array to be used at any
time, until it is overwritten when a new menu is created.

How would I go about this?
Any help will be most appreciated!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to