Answer the question
In order to leave comments, you need to log in
How to implement data filtering through Ajax?
Hello. Help deal with the issue. It is necessary to filter the data on the site according to several criteria, everything is OK with this, I collected the data and sent it to the server, I made a selection on the server-> received it on the client. Now faced with a problem, or rather began to reinvent the wheel because I do not know the truth. It is necessary that after the reload of the page, the selected criteria remain in place. As I understand it, this is done through the url parameters using the GET method, but what about ajax, let's say I hang a handler on the submit form so that the reload does not occur, e.preventDefault();
but then the link is not generated, I started to sculpt a type bike with the handler in js to generate this url
history.pushState('', 'New Page Title', '/filter?' + $(this).serialize());
But something seems to me that I don’t know something, tell me how these features are made more correctly. Thank you in advance.
Answer the question
In order to leave comments, you need to log in
Alternatively, you can push the filter parameters into the hash of the page url.
1) selected filter parameters
2) formed a string like: key1=val&key2=val&key3=val
3) stuffed it into a hash: window.location.hash= "key1=val&key2=val&key3=val"
4) sent an ajax request
5) updated the page
6 ) read the hash, etc.
Write filter values to the session and update them on the client after page reload.
I think in your case it is best to write in cookies
google document.cookie or you can use my module for working with cookies
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question