adding and displaying favorite names list using jquery/ajax without database


using my website people can search any names in world. users can add their particular name to favorite list. each user can see their favorite names list in another page(names those added by user in one session). can you suggest a best method to do this using jquery/ajax. Thankz.


You could use <a href="http://www.w3.org/TR/webstorage/#the-localstorage-attribute" rel="nofollow">local storage</a> to save the data. It works as easy as this:

localStorage.setItem('key', 'value'); localStorage.getItem('key'); // returns 'value'

You could save the names using an incrementing key:

localStorage.setItem('name-' + (localStorage.length + 1).toString(), 'favName'); // Names stored as 'name-0', 'name1', ...

And then, to retrieve the list:

var names = new Array(); if (localStorage) { if (localStorage.length) { for (var i = 0; i < localStorage.length; i++) { names[i] = localStorage.getItem('name-' + i.toString()); } } else { names[0] = 'You have no favorite names stored'; } }

There are some plugins that provide fallbacks on browsers that don't support web storage (Even on ie6), like <a href="https://github.com/jarednova/jquery-total-storage" rel="nofollow">totalStorage</a> or <a href="http://www.jstorage.info/" rel="nofollow">jstorage</a>.


  • Google OAuth: can't get refresh token with authorization code
  • import scipy.sparse failed
  • CXF JAXB JAXBEncoderDecoder unmarshalling error : unexpected element when having qualified elements
  • Redshift Querying: error xx000 disk full redshift
  • Android changing fragment order inside FragmentPagerAdapter
  • python script hangs on input method when running spark
  • IE11 throwing “SCRIPT1014: invalid character” where all other browsers work
  • Jquery popup on mouse over of calendar control
  • Adjust width of select element according to selected option's width
  • How to use JavaScript to determine whether a file exists in a directory?
  • ADO and msqli connections very slow
  • How can I extract results of aggregate queries in slick?
  • How do I get HTML corresponding to current DOM tree?
  • Rails Find when some params will be blank
  • PHP buffered output depending on server setting?
  • How to create a file in java without a extension
  • Django rest serializer Breaks when data exists
  • Debugging ASP.NET on a built-in web server suddenly stops
  • Deselecting radio buttons while keeping the View Model in synch
  • How to recover from a Spring Social ExpiredAuthorizationException
  • ILMerge & Keep Assembly Name
  • Trying to switch camera back to front but getting exception
  • Large data - storage and query
  • jQuery tmpl and DataLink beta
  • How can I estimate amount of memory left with calling System.gc()?
  • WOWZA + RTMP + HTML5 Playback?
  • How to disable jQuery.jplayer autoplay?
  • InvalidAuthenticityToken between subdomains when logging in with Rails app
  • trying to dynamically update Highchart column chart but series undefined
  • Free memory of cv::Mat loaded using FileStorage API
  • CSS Applying specific rule for a specific monitor resolution with only CSS is posible?
  • Angular 2 constructor injection vs direct access
  • Setting background image for body element in xhtml (for different monitors and resolutions)
  • embed rChart in Markdown
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]
  • Programmatically clearing map cache
  • How to get NHibernate ISession to cache entity not retrieved by primary key
  • costura.fody for a dll that references another dll
  • How can I use `wmic` in a Windows PE script?
  • Unable to use reactive element in my shiny app