jQuery iterate through array on click

DarkAngelz

New Member
I have tried to look everywhere for a solution but I can't seem to understand how this can be properly done. Essentially I have an XML that I want to pull data from. I want the page to load the first entry, once the user clicks the forward button I want it to iterate through the XML until it reaches the end. The same would go for the back button. \[code\] $(document).ready(function(){ var name = []; var description = []; var html_screenshot_01 = []; var html_screenshot_02 = []; var site_link = []; var source_link = []; var demo_link = []; $.ajax({ type: "GET", url: "projects_html.xml", dataType: "xml", success: function(xml) { $(xml).find('name').each(function(){ name.push($(this).text()); }); $(xml).find('description').each(function(){ description.push($(this).text()); }); $(xml).find('html_screenshot_01').each(function(){ html_screenshot_01.push($(this).text()); }); $(xml).find('html_screenshot_02').each(function(){ html_screenshot_02.push($(this).text()); }); $(xml).find('site_link').each(function(){ site_link.push($(this).text()); }); $(xml).find('source_link').each(function(){ source_link.push($(this).text()); }); $(xml).find('demo_link').each(function(){ demo_link.push($(this).text()); }); $(xml).find('projects').each(function(){ $('#name').empty().append(name[0]); $('#description').empty().append(description); $("img#html_screenshot_01").attr("src", html_screenshot_01); $("img#html_screenshot_02").attr("src", html_screenshot_02); $("a#site_link").attr("src", site_link); $("a#source_link").attr("src", source_link); $("a#demo_link").attr("src", demo_link); $('a#site_link').filter(function() {return $.trim($(this).text()) === ''}).css("visibility", "hidden") $('a#source_link').filter(function() {return $.trim($(this).text()) === ''}).css("visibility", "hidden") $('a#demo_link').filter(function() {return $.trim($(this).text()) === ''}).css("visibility", "hidden") }); } }); $("#next").click(function() { var i = 0; i++; $('#name').empty().append(name); return false; }); $("#back").click(function() { alert('back'); }); });\[/code\]
 
Back
Top