SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Sep 2007
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Reusing an ajax response

    I have a small site that displays pages with information about a musician. This page initially includes several different types of information, including a list of the musician's albums.

    When a user selects an album I am using ajax methods to get the album information, and the lyrics to all the songs. Every time a user clicks on a different album ajax gets the new information. It works well.

    However, when a user re selects an album, the ajax call is made again. I am having a hard time trying to figure out how to store that information for re-use so that the ajax call does not have to be re made.

    How can I format or create the array / hash / object so I can check if it is present, and then use it if it is. Everyone says we should cut down on server calls if possible.

    I use prototype 1.6.

  2. #2
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How about putting the response data into an invisible DIV and append it to the doc. Make sure the div has a unique ID which corresponds to the album name/ID. Then before making the call you can check whether a DIV with the ID of [ALBUM ID] exists in the document... If it does... then don't call, and gather the data from that div instead.
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •