views:

110

answers:

1

I am coming up dry with my searches all morning for a starting place with this. I will throw out a very rough example of what I am looking to do.

I want a div populated with cumulative id elements from previously visited pages within the site. Think recently viewed products @amazon for instance.

So I want to grab 2 elements for each previously viewed page and throw them into a #div via an ajax request. I am a jquery cobbler and can do OK with some sort of starting place but I am coming up dry on starting places with this one.

So my recent #div will fetch #recent-title and #recent-image from say the last five visited pages.

Any direction is graciously appreciated.

A: 

This kind of feature is best implemented in the server side script.

In each page that you need to be tracked, put a code to store the page id into the database.

In the page with recent visited div, fetch the database content that store recent visited page id, use it to get the title and image contained in the actual pages, then put the result there. This can be done directly when page load, then updated in some time interval using ajax request.

You can put the URL to your code here and I will try to help you to tweak it.

Donny Kurnia
Hi Donny thanks for chiming in I really appreciate it. Unfortunately this has to be deployed to a hosted e-commerce solution (shopify) and there is no option for server side ruby scripts. I will have to pull this off with a tracker cookie of some sort and this is very new territory for me. Do you think this is possible without server side access?
Jamie
Well, in that case, you may consider using jQuery cookie plugins: http://plugins.jquery.com/project/cookie. In each product page, put jQuery code to store the top title and image `id` into cookies (remember that the cookie can only hold limited size of data, so store as little as possible). Then in your page, iterate the cookies value, then maybe make the AJAX request to display the image based on `id` stored in there.
Donny Kurnia
Since my solution above using cookie, the result will be unique for each visitor, since the cookie is stored in the browser, not in server. My latest visit will be different from your latest visit result.
Donny Kurnia
Thanks Donnie,I am tihnking the last 6 pages in the history so hopefully that won't cramp the cookie plugin you linked to. Thanks!
Jamie