Hi, I have created a function that binds behavior to a set of links, the result of clicking being that the container div of the navigations gets a new background image, and eventually gets html injected into the div as well (currently that part is not coded)...
Given the following function, it seems like there would be a better way to handle accessing the JSON file each time a link is pressed than doing a $.getJSON each time. Is there a prescribed way for storing that JSON after the first call and being able to access it later? Or, could I set up variables each time the particular part of the JSON file is called and if that same button is clicked again, return the variable instead of accessing the JSON? Thanks for the help, $.getJSON("/dev/home/pp.json", function(data){ $('.pomonaPeople').css('background', 'url(' + data.items [0].background + ' )' ); $('.pomonaPeople').append(data.items[0].content); $('.pomonaPeople .loading').fadeOut(FADE); }); // create navigation var ppButton = $('#pp-nav ul li a'); ppButton.click( function(event) { event.preventDefault(); var aIndex = $(this).attr('href'); var destination = $('.pomonaPeople'); destination.append('<div class="loading"></div>'); $.getJSON("/dev/home/pp.json", function(data){ destination.css('background', 'url(' + data.items [aIndex].background + ' )' ); destination.find('.loading').fadeOut(FADE); }); });