Let's say I have a "report" page that can be customized via Javascript. Say I have start_date, end_date and type ("simple", or "full") that can be changed. Now I want the address bar to always contain a "permalink" of the current (customized) view, so the user can easily copy it.
If I'd do this without Ajax, I would simply use something like "/report/?start_date=2010-01-01&end_date=2010-01-31&type=full" as a permalink. But since I want to update the URL from Javascript, I need to use the anchors (#), otherwise the whole page would need to be reloaded.
Is there any best practice for how to generate permalinks in this case? I'd go with something like "/report/#start_date=2010-01-01,end_date=2010-01-31,type=full" and parse that thing in Javascript. Is there any better or more generally accepted way to deal with this?
Also, is there any better way to deal with the Javascript side rather than simply parsing everything?
Thanks.
Although X in Ajax stands for XML, JSON is preferred over XML nowadays because of its many advantages such as being a part of JavaScript, thus being lighter in size. Both JSON and XML are used for packaging information in the Ajax model.
Ajax development offers an enriched user experience which is one of the core benefits. It allows the web pages to update by exchanging a little amount of data with the server. In this way, it is possible to create parts of a web page without having to reload the whole page.
In 2015 Google announced that Google was now generally able to crawl, read and parse JavaScript without any issues, making the AJAX crawling scheme obsolete.
Ajax's primary advantage is its ability to improve performance and usability for web applications. Ajax allows applications to render with no data. This reduces server traffic. Web developers can reduce the time taken to respond on both sides of the request.
I ended up using URLs of the form http://example.com/resource/#param1=value1¶m2=value2. I wrote some Javascript code to deal with this (parse/update the URL). The code is on Github, if anyone is interested.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With