How to pass variables between PHP pages via JavaScript?

6

I was doing a search in PT and EN on how to pass variables from one page to another via JavaScript, although I found a lot of information I kept on with the question of how best to do it.

I have some fields of a table (paginated) with filter, via JavaScript that filters according to the elements present in that same table. But when I turn the page the filter I used is deleted, because it is called again my script script .

I want to keep the filter active in the same table by changing the page.

My question is different from Simple pagination in jQuery / Javascript , because I already have pagination, I already have filters, I have everything working. But every time I turn the page, the filter disappears. How do I pass my filter variables to the other page for use in my filter script ?

    
asked by anonymous 08.04.2014 / 17:11

1 answer

4

Three ways to do this:

  • Pass the Ajax filter to the server, and save it in session for later use

  • Save the filter to a cookie generated and consumed by JavaScript

  • Save filter in localStorage (less supported, does not work in older browsers)

Except for the localStorage compatibility problem, the three solutions look equally good. Use the one that most closely matches the code you already have.

    
08.04.2014 / 17:18