How to remember last ajax state when click back in browse -


i have category browsing page shows 48 products, , after customers click next button, triggers ajax call load next 48 products, page has 96 products , url keeps same. , then, customers click 1 product page, , go product page, , click in browse going browsing page, , page reloading , 24 products shown.

so question how keep last ajax state, when customers click back, still see 48 results.

i see llbean can it, wondering how implement this? http://www.llbean.com/llb/shop/509723?nav=ln-26&page=active-clothing

thanks!

yes can either cookie storage on client side, or session data on server side. guess recommend cookie storage since basic insensitive data.

you can use following code write, read , erase cookie data:

function createcookie(name, value, days) {     if (days) {         var date = new date();         date.settime(date.gettime() + (days * 24 * 60 * 60 * 1000));         var expires = "; expires=" + date.togmtstring();     } else var expires = "";     document.cookie = escape(name) + "=" + escape(value) + expires + "; path=/"; }  function readcookie(name) {     var nameeq = escape(name) + "=";     var ca = document.cookie.split(';');     (var = 0; < ca.length; i++) {         var c = ca[i];         while (c.charat(0) == ' ') c = c.substring(1, c.length);         if (c.indexof(nameeq) == 0) return unescape(c.substring(nameeq.length, c.length));     }     return null; }  function erasecookie(name) {     createcookie(name, "", -1); } 

for example, set cookie named numresults store how many results client browsing:

var data = readcookie("numresults"); if (data != null && data != "") {     //in case, have data, load many results } else {     createcookie("numresults", 48, 30); //create cookie, if doesn't exist } 

and when make ajax call increase results number, add:

createcookie("numresults", newnumber, 30); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -