Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permalink best practices for ajax pages

Tags:

ajax

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.

like image 308
ibz Avatar asked Feb 23 '10 08:02

ibz


People also ask

What is the preferred data format for AJAX programming?

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.

How AJAX help build effective web pages?

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.

Can Google crawl AJAX content?

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.

Does AJAX improve performance?

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.


1 Answers

I ended up using URLs of the form http://example.com/resource/#param1=value1&param2=value2. I wrote some Javascript code to deal with this (parse/update the URL). The code is on Github, if anyone is interested.

like image 192
ibz Avatar answered Oct 04 '22 06:10

ibz