tableau de la rubrique XML

  • mindfullsilence
  • Professor
  • Professor
  • Avatar de l’utilisateur
  • Inscription: Aoû 04, 2008
  • Messages: 846
  • Status: Offline

Message Décembre 7th, 2009, 6:33 pm

J'ai besoin de créer un tableau de points. le tableau doit contenir le même nombre de points que mon fichier XML contient "image" tags. Puis, j'ai besoin de jQuery pour créer un <li> </ li> et l'annexer à un déjà établi <ul> </ ul> dans le fichier html pour chaque item dans mon tableau. heres mes codes, en abrégé:

HTML Code: [ Select ]
<div id="webthumbcontainer">
     <ul id="webthumblist">
 
     </ul>
</div>
 
  1. <div id="webthumbcontainer">
  2.      <ul id="webthumblist">
  3.  
  4.      </ul>
  5. </div>
  6.  


XML Code: [ Select ]
<category id="web">
      <image>
         <link>tadesign/images/carcare.jpg</link>
         <description>Description text goes here about carcaredetail</description>
      </image>
      <image>
         <link>tadesign/images/monster.jpg</link>
         <description>Description text goes here about monster resolution</description>
      </image>
      <image>
         <link>tadesign/images/rantingbill.jpg</link>
         <description>Description text goes here about rantingbill</description>
      </image>
      <image>
         <link>tadesign/images/voltecsite.jpg</link>
         <description>Description text goes here about voltec design</description>
      </image>
</category>
 
  1. <category id="web">
  2.       <image>
  3.          <link>tadesign/images/carcare.jpg</link>
  4.          <description>Description text goes here about carcaredetail</description>
  5.       </image>
  6.       <image>
  7.          <link>tadesign/images/monster.jpg</link>
  8.          <description>Description text goes here about monster resolution</description>
  9.       </image>
  10.       <image>
  11.          <link>tadesign/images/rantingbill.jpg</link>
  12.          <description>Description text goes here about rantingbill</description>
  13.       </image>
  14.       <image>
  15.          <link>tadesign/images/voltecsite.jpg</link>
  16.          <description>Description text goes here about voltec design</description>
  17.       </image>
  18. </category>
  19.  


JAVASCRIPT Code: [ Select ]
$.ajax({
url: "js/img.xml",type: 'GET',dataType: 'xml',timeout: 1000,error: function(){alert('Error loading XML document');},
 
 
success: function()
   {
   
   $(this).find('label').each(function(){
                         var blocks = $(xml).makeArray($(this).each('images'));
 
                         $('<li><a href="#"></a></li>')
                             .html(blocks).each()
                             .appendTo('#webthumblist');
       });
   
       }
   
});
 
  1. $.ajax({
  2. url: "js/img.xml",type: 'GET',dataType: 'xml',timeout: 1000,error: function(){alert('Error loading XML document');},
  3.  
  4.  
  5. success: function()
  6.    {
  7.    
  8.    $(this).find('label').each(function(){
  9.                          var blocks = $(xml).makeArray($(this).each('images'));
  10.  
  11.                          $('<li><a href="#"></a></li>')
  12.                              .html(blocks).each()
  13.                              .appendTo('#webthumblist');
  14.        });
  15.    
  16.        }
  17.    
  18. });
  19.  


Im essayant de mon mieux ici, mais je ne sais pas assez sur XML, JavaScript, jQuery, ou Ajax pour obtenir ce faire par moi-même. Ive a fait des recherches comme un fou, mais Id appreciate your guys entrée.

Essentiellement, je devrais obtenir 4 objets dans mon tableau. Je voudrais également avoir 4 <li> dans mon <ul id="webthumblist">.
Use your words like arrows to shoot toward your goal.
  • Anonymous
  • Bot
  • No Avatar
  • Inscription: 25 Feb 2008
  • Messages: ?
  • Loc: Ozzuland
  • Status: Online

Message Décembre 7th, 2009, 6:33 pm

  • mindfullsilence
  • Professor
  • Professor
  • Avatar de l’utilisateur
  • Inscription: Aoû 04, 2008
  • Messages: 846
  • Status: Offline

Message Décembre 8th, 2009, 11:57 am

regarde comme si j'étais proche, heres ce que quelqu'un sur un autre forum m'a donné:

JAVASCRIPT Code: [ Select ]
$.ajax({
url: "js/img.xml",type: 'GET',dataType: 'xml',timeout: 1000,error: function(){alert('Error loading XML document');},
 
 
success: function(xml)
   {
   
   $(xml).find('#web image').each(function(){
                     $("#webthumblist").append("<li><a href=\"#\" id=\"" + $(xml).find('#web image').index(this) + '></a></li>');
                  });
};
});
 
  1. $.ajax({
  2. url: "js/img.xml",type: 'GET',dataType: 'xml',timeout: 1000,error: function(){alert('Error loading XML document');},
  3.  
  4.  
  5. success: function(xml)
  6.    {
  7.    
  8.    $(xml).find('#web image').each(function(){
  9.                      $("#webthumblist").append("<li><a href=\"#\" id=\"" + $(xml).find('#web image').index(this) + '></a></li>');
  10.                   });
  11. };
  12. });
  13.  
Use your words like arrows to shoot toward your goal.
  • mindfullsilence
  • Professor
  • Professor
  • Avatar de l’utilisateur
  • Inscription: Aoû 04, 2008
  • Messages: 846
  • Status: Offline

Message Décembre 8th, 2009, 12:09 pm

Heres une question, mon javascript est en cours d'exécution sur l'ensemble du réseau au lieu de chaque article. Vous ne savez pas pourquoi.

Par exemple


Regardez les paragraphes, theyre tout produit en fonction de l'appel ajax xml. heres the jQuery pour le contenu généré par l'alinéa:

JAVASCRIPT Code: [ Select ]
$(xml).find('#web description').each(function(){
         var desc = $(xml).find('#web description').text();
                     $("#textcontainer").append('<p>' + desc + '</p');
   });
 
  1. $(xml).find('#web description').each(function(){
  2.          var desc = $(xml).find('#web description').text();
  3.                      $("#textcontainer").append('<p>' + desc + '</p');
  4.    });
  5.  


Et voici mon fichier XML
XML Code: [ Select ]
<root>
   <category id="web">
      <image></image>
      <link>tadesign/images/carcare.jpg</link>
      <description>Description text goes here about carcaredetail</description>
     
      <image></image>
      <link>tadesign/images/monster.jpg</link>
      <description>Description text goes here about monster resolution</description>
     
      <image></image>
      <link>tadesign/images/rantingbill.jpg</link>
      <description>Description text goes here about rantingbill</description>
     
      <image></image>
      <link>tadesign/images/voltecsite.jpg</link>
      <description>Description text goes here about voltec design</description>
     
   </category>
</root>
 
  1. <root>
  2.    <category id="web">
  3.       <image></image>
  4.       <link>tadesign/images/carcare.jpg</link>
  5.       <description>Description text goes here about carcaredetail</description>
  6.      
  7.       <image></image>
  8.       <link>tadesign/images/monster.jpg</link>
  9.       <description>Description text goes here about monster resolution</description>
  10.      
  11.       <image></image>
  12.       <link>tadesign/images/rantingbill.jpg</link>
  13.       <description>Description text goes here about rantingbill</description>
  14.      
  15.       <image></image>
  16.       <link>tadesign/images/voltecsite.jpg</link>
  17.       <description>Description text goes here about voltec design</description>
  18.      
  19.    </category>
  20. </root>
  21.  
Use your words like arrows to shoot toward your goal.
  • UPSGuy
  • Lurker ಠ_ಠ
  • Web Master
  • Avatar de l’utilisateur
  • Inscription: Juil 25, 2005
  • Messages: 2735
  • Loc: Nashville, TN
  • Status: Offline

Message Décembre 9th, 2009, 6:50 am

Vous n'avez pas besoin de la fermeture du point-virgule param succès et vous avez besoin pour simplifier / votre retravailler peu trouver à l'intérieur (). Each () pour éviter de mettre tous les desc. en une seule fois pour chaque entrée que vous avez (et fermer vos </ p> tag). Essayez comme ceci:

Code: [ Select ]
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script>
</head>
<body>

<div id="textcontainer">
Some text here
</div>

<script language="javascript">
$.ajax({
    url: "img.xml",type: 'GET',dataType: 'xml',timeout: 1000,error: function(){alert('Error loading XML document');},
    success: function(xml) {
        $(xml).find('#web description').each(function(){
            $("#textcontainer").append('<p>' + $(this).text() + '</p>');
        });
    }
});
</script>
</body>
</html>
  1. <html>
  2. <head>
  3. <script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script>
  4. </head>
  5. <body>
  6. <div id="textcontainer">
  7. Some text here
  8. </div>
  9. <script language="javascript">
  10. $.ajax({
  11.     url: "img.xml",type: 'GET',dataType: 'xml',timeout: 1000,error: function(){alert('Error loading XML document');},
  12.     success: function(xml) {
  13.         $(xml).find('#web description').each(function(){
  14.             $("#textcontainer").append('<p>' + $(this).text() + '</p>');
  15.         });
  16.     }
  17. });
  18. </script>
  19. </body>
  20. </html>


(My img.xml était identique à la vôtre été faites dans votre dernier exemple)
I'd love to change the world, but they won't give me the source code.

Afficher de l'information

  • Total des messages de ce sujet: 4 messages
  • Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 165 invités
  • Vous ne pouvez pas poster de nouveaux sujets
  • Vous ne pouvez pas répondre aux sujets
  • Vous ne pouvez pas éditer vos messages
  • Vous ne pouvez pas supprimer vos messages
  • Vous ne pouvez pas joindre des fichiers
 
 

© 2011 Unmelted, LLC. Ozzu® est une marque déposée de Unmelted, LLC