I have a web application and want to be able to pass an object ID via the URL:
www.example.com/?id=someObjectID
I then want to retrieve the Object data from the server (e.g. with an Ajax call).
What is best practice to handle this?
I came up with:
analyse the URL with JavaScript.
pros:
- everything is pure client side JS
cons:
- there is no standard way for URL parameter handling in JS
get the URL parameters server side and render them into the HTML response (e.g. inside a variable). Then make the ajax request client side.
pros:
- easy URL parameter handling server side (e.g. with express)
cons:
- parameter information makes a round trip to the server
- server side rendering of the website (I could start render everything server side)
Are there any other options?
What are best practice here?
Is there any standard libraries/tools?