Question

I have a catalogue of products that comes from a json file. I use different sorting methods to order it in one way or another. I would like to change the criterion of order when some checkboxes are checked, using javascript.

My question: Can I change the type of php sort using javascript, without reloading the page?

Thanks.

Was it helpful?

Solution

If you want/have to sort your data with PHP, then you will have to send a request (Ajax: http://api.jquery.com/jQuery.get/) to your server and do the PHP magic. On response, you re-display your data via JS.

If the kind of sorting you need to perform is rather simple, then try to do it with JS; will be much(!) faster. Maybe this helps: https://datatables.net/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top