Hi,
There was a problem with the particular version of jQuery that was bundled with the downloadable code from the Packt website.
Take a look at the companion site for a working version: http://book.learningjquery.com/2509_06_code/dictionary.html --Karl _________________ Karl Swedberg www.englishrules.com www.learningjquery.com On May 12, 2008, at 1:58 PM, JQuery wrote:
I could see the content of the d.xml file (alert('data: ' + data), but I could not see the alert('inside each function'). I think jquery did not recognize d.xml is an xml file. Any idea? Thanks $(document).ready(function() { $('#letter-d .button').click(function() { $.get('d.xml', function(data) { alert('data: ' + data); $('#dictionary').empty(); $(data).find('[EMAIL PROTECTED]').each(function() { var $entry = $(this); alert('inside each function'); var html = '<div class="entry">'; html += '<h3 class="term">' + $entry.attr('term') + '</h3>'; html += '<div class="part">' + $entry.attr('part') + '</div>'; html += '<div class="definition">' html += $entry.find('definition').text(); var $quote = $entry.find('quote'); if ($quote.length) { html += '<div class="quote">'; $quote.find('line').each(function() { html += '<div class="quote-line">' + $(this).text() + '</ div>'; }); if ($quote.attr('author')) { html += '<div class="quote-author">' + $quote.attr('author') + '</div>'; } html += '</div>'; } html += '</div>'; html += '</div>'; $('#dictionary').append($(html)); }); }); }); }); Content of d.xml file <?xml version="1.0" encoding="UTF-8"?> <entries> <entry term="DANCE" part="v.i."> <definition> To leap about to the sound of tittering music, preferably with arms about your neighbor's wife or daughter. There are many kinds of dances, but all those requiring the participation of the two sexes have two characteristics in common: they are conspicuously innocent, and warmly loved by the vicious. </definition> </entry> <entry term="DAY" part="n."> <definition> A period of twenty-four hours, mostly misspent. This period is divided into two parts, the day proper and the night, or day improper <![CDATA[—]]> the former devoted to sins of business, the latter consecrated to the other sort. These two kinds of social activity overlap. </definition> </entry> <entry term="DEBT" part="n."> <definition> An ingenious substitute for the chain and whip of the slave- driver. </definition> <quote author="Barlow S. Vode"> <line>As, pent in an aquarium, the troutlet</line> <line>Swims round and round his tank to find an outlet,</line> <line>Pressing his nose against the glass that holds him,</line> <line>Nor ever sees the prison that enfolds him;</line> <line>So the poor debtor, seeing naught around him,</line> <line>Yet feels the narrow limits that impound him,</line> <line>Grieves at his debt and studies to evade it,</line> <line>And finds at last he might as well have paid it.</line> </quote> </entry> <entry term="DEFAME" part="v.t."> <definition> To lie about another. To tell the truth about another. </definition> </entry> <entry term="DEFENCELESS" part="adj."> <definition> Unable to attack. </definition> </entry> <entry term="DELIBERATION" part="n."> <definition> The act of examining one's bread to determine which side it is buttered on. </definition> </entry> <entry term="DELUSION" part="n."> <definition> The father of a most respectable family, comprising Enthusiasm, Affection, Self-denial, Faith, Hope, Charity and many other goodly sons and daughters. </definition> <quote author="Mumfrey Mappel"> <line>All hail, Delusion! Were it not for thee</line> <line>The world turned topsy-turvy we should see;</line> <line>For Vice, respectable with cleanly fancies,</line> <line>Would fly abandoned Virtue's gross advances.</line> </quote> </entry> <entry term="DENTIST" part="n."> <definition> A prestidigitator who, putting metal into your mouth, pulls coins out of your pocket. </definition> </entry> <entry term="DIE" part="n."> <definition> The singular of "dice." We seldom hear the word, because there is a prohibitory proverb, "Never say die." At long intervals, however, some one says: "The die is cast," which is not true, for it is cut. The word is found in an immortal couplet by that eminent poet and domestic economist, Senator Depew: </definition> <quote> <line>A cube of cheese no larger than a die</line> <line>May bait the trap to catch a nibbling mie.</line> </quote> </entry> <entry term="DIPLOMACY" part="n."> <definition> The patriotic art of lying for one's country. </definition> </entry> <entry term="DISTANCE" part="n."> <definition> The only thing that the rich are willing for the poor to call theirs, and keep. </definition> </entry> </entries>