On Nov 4, 6:22 am, bakman <bakman.bak...@gmail.com> wrote:
> I am generating elements (img's) based on data from an xml file.
> Once that is done, I want to determine the number of icons that were
> generated.
>
> as naive as i am, i do a: alert($('img').size())
> result: 0, which isn't the case
>
> how can i determine them after they have generated ?


Why not:

  document.images.length

Or increment a counter as you go.


> **********************************************
> function dataloader(location,service,div){
>         $.ajax({
>                 type: "GET",
>                 url: "includes/data.xml",
>                 dataType: "xml",
>                 success: function(xml) {
>
>                         $(xml).find('group').each(function(){
>                                 if($(this).attr("name") == service){
>                                 $(this).find("Service").each(function(){

the $() function is expensive to run, so run it as infrequently as
possible, e.g.

  $(xml).find('group').each(function(){
      var element = $(this);
      if (element.attr("name") == service) {
          element.find("Service").each(function() {


>                                 var type = $(this).find("Type").text()
>                                 var host = $(this).find("Host").text()
>                                 var name = $(this).find("Name").text()
>                                 var site = $(this).find("Site").text()

          var service = $(this);
          var type = service.find("Type").text();
          var host = service.find("Host").text();
          var name = service.find("Name").text();
          var site = service.find("Site").text();

and so on.


--
Rob

Reply via email to