No Obvious Answer - Query-Strings and Javascript
Posted
by
nchaud
on Pro Webmasters
See other posts from Pro Webmasters
or by nchaud
Published on 2012-12-03T12:35:13Z
Indexed on
2012/12/03
17:20 UTC
Read the original article
Hit count: 261
url
Say I have this main page /my-site/all-my-bath-soaps
which lists all my products.
It has a search filter text box that uses javascript to filter the products they want to see on that page (the URL doesn't change as they filter).
Now from many other parts of the site I want to navigate to this products-page and see specific products. E.g.
<a href="/my-site/all-my-bath-soaps?filter='Nivea-Soap'">
will go to /all-my-bath-soaps
and apply javascript filtering to see just that product and hide all dom nodes for the other products.
The problem is if the user changes the text in the filter from 'Nivea-Soap' to 'Lynx' the javascript will work fine and show the new products but the URL stays at ?filter='Nivea-Soap'
.
Is there anything I can do about this? Of course, I don't want to reload the page with a new query string every time they change the search criteria. Somehow it'd be great to move the ?filter=... criteria into POST data instead - but how can I do this with a link I don't know...
© Pro Webmasters or respective owner