Hi, all...

I'm trying to parse and output some XML using jQuery
so that I get an output similar to this:

Air Conditioners
XC21
XC22
XC23

Furnaces
XF30
XF31
XF32

I'm using the .each function of jQuery to loop over
the Categories XML (on one file), then again on the
Products XML (on a separate file.

The problem is, I can get the Air Conditioners category
to output, but then the entire list of AC models
(XC21, etc) outputs as one item instead of individually.

Here's the jQuery... anyone spot my flow in logic?

Thanks,

Rick

$(document).ready(function() {

   $('#get_categories_and_products').click(function() {
        
      $.ajax ({   type:      "get",
                  url:       "categories.xml",
                  dataType:  "xml",
                  success:   function(xml) {    // list categories

                     $(xml).find("Category").each(function() {

 
$('#categories').append($(this).find('CategoryName').text() + '<br />')

                         currentCategory =
$(this).find('CategoryName').text();

                         $.ajax  ({  type:        "get",
                                     url:         "lennoxproducts.xml",
                                     dataType:    "xml",
                                     success:     function(xml) {     //
list products for category
        

 
$(xml).find("Category").each(function() {
        

                                           if  ( $(this).text() ==
currentCategory
                                               )

                                               { var currentProductName =
$(this).next().find('ModelName').text();
 
$('#categories').append(currentProductName + '<br />')
                                               }

                                        });  
                                     }
                         });
                      });
                   }
        });
   });
});



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:349502
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to