Load data by ajax with Jquery and place parameters in url

0

I have a search form that I want the results to return to me with ajax in a single sector without loading the whole page.

I'm using the function $.get() of Jquery, but the problem would be that when I return the results of the search and want to go to the content I would not have the results when I went back.

Since you do not put the parameters in the url when you use $.get() of jquery How could I implement a solution to this?

    
asked by Leoh 22.08.2016 в 16:52
source

2 answers

1

You can save the results of your search in session or in cookies and with this you do not lose the searches made. In javascript is sessionStorage, its use is highly recommended. More information here : Storing in the client: LocalStorage, SessionStorage and Cookies

You can also use HTML5 history API. More information here: Manipulating the browser history

Good luck!

    
answered by 23.08.2016 / 05:23
source
0

> > > > > When I go to the content and I want to return is no longer present the results of the search

Of course because ajax does not intervene in the navigability that the browser implements, you would be in the load of the page (whether it is entered for the first time or if it is a product of a back) that you should re-invoke the $ .get to reload the data.

If you do not want to lose the data that you loaded with the $ .get you could open the link in a popup so the back would not affect, you could use window.open() or else in the link indicate the target="_blank" .

    
answered by 22.08.2016 в 21:16