reloading page after fetching data from ajax

I am using ajax to fetch data dynamically, but there is a problem. When I refresh the page the fetched data is lost. I want the data to remain the same after I refresh the page.Suppose this is my page: /* fetching data which matches the keyword*/function Search() $.post(“search.php”, search_word: $(‘#searchInput’).val() , function(data) if(data) $(‘#results’)….

via PHP Website Development » Search Results » ajax:

reloading page after fetching data from ajax

I am using ajax to fetch data dynamically, but there is a problem. When I refresh the page the fetched data is lost. I want the data to remain the same after I refresh the page.
Suppose this is my page:







When I click on the search button the data which came in results div would be gone after refreshing the page.
………………………………………….

Save that data in session or in database and then fetch from there because after refreshing page get and post variables destroy automatically.
………………………………………….

Consider using cookie data.
This jQuery plugin will do the trick: http://plugins.jquery.com/project/cookie
$.cookie(‘example’, ‘foo’); //the name is example and that value is foo.getting the cookie’s value is simple…
alert($.cookie(‘example’);So after you load your data dynamically you could either store that data in a cookie. Though this may be a bad solution if your fetching a large amount of data.
This question is hard to answer due to the lack of example code and therefore not understanding your intent or how/what you’re doing.

For more info: reloading page after fetching data from ajax

PHP Website Development » Search Results » ajax

reloading page after fetching data from ajax

Share this post:

Related Posts

Leave a Comment