Ajax driven site and comment links

264 views
Skip to first unread message

Andrew Willey

unread,
Jul 27, 2011, 12:24:48 AM7/27/11
to Disqus Developers
In a site feature, the page allows the user to turn a comic book page
without refreshing. Each page loads the image and an associated
"post" for which I am dynamically refreshing the disqus comments. To
do this, I had to modify my URL schema to include the hashbang, so the
URL for a given page might look like this:

/some-book-title/some-chapter-title/#!20

This works great, and the comments load properly. The problem comes
when you try to link to comments directly (like from the moderator
panel). Those links look like this:

/some-book-title/some-chapter-title/#!20#comment-249780218

This is a malformed URL, and so the comments don't load for the page
properly. Any thoughts on how I can make this work?

Examples -
Normal page url
http://rigbythebarbarian.com/reader/rigby-the-barbarian/rigby-and-rider/#!20

Link from moderator panel
http://rigbythebarbarian.com/reader/rigby-the-barbarian/rigby-and-rider/#!20#comment-266144777

Message has been deleted

neoascetic

unread,
Mar 26, 2012, 5:16:18 AM3/26/12
to disqu...@googlegroups.com
Same problem, please do something

Mark Goodge

unread,
Mar 26, 2012, 5:33:17 AM3/26/12
to disqu...@googlegroups.com
On 26/03/2012 10:15, neoascetic wrote:
> +1

>
> On Wednesday, July 27, 2011 3:24:48 PM UTC+11, Andrew Willey wrote:
>
> In a site feature, the page allows the user to turn a comic book page
> without refreshing. Each page loads the image and an associated
> "post" for which I am dynamically refreshing the disqus comments. To
> do this, I had to modify my URL schema to include the hashbang, so the
> URL for a given page might look like this:
>
> /some-book-title/some-chapter-​title/#!20
>
> This works great, and the comments load properly. The problem comes
> when you try to link to comments directly (like from the moderator
> panel). Those links look like this:
>
> /some-book-title/some-chapter-​title/#!20#comment-249780218
>
> This is a malformed URL, and so the comments don't load for the page
> properly. Any thoughts on how I can make this work?

Make it work without Javascript (and hence without the hashbang) as
well, so that

/some-book-title/some-chapter-​title/#!20

and

/some-book-title/some-chapter-​title/20

go to the same place (the latter can redirect to the former if you want).

Then pass the non-hashbang version to Disqus via the URL parameter, so
that your comments URL looks like this:

/some-book-title/some-chapter-​title/20#comment-249780218

which you can then redirect internally if you like so that the visible
URL in the browser address bar matches your preferred formatting.

As a general principle, if you're using ajax techniques with URL
fragments then it's always a good idea to make it work without them as
well. That means that it will work for users with Javascript disabled or
restricted, which not only solves your problem with direct bookmarks and
links to internal pages but makes it much more SEO-friendly and more
accessible to users with visual disabilities.

Mark
--
Sent from my Babbage Difference Engine 2
http://mark.goodge.co.uk

Message has been deleted

neoascetic

unread,
Mar 26, 2012, 5:45:06 AM3/26/12
to disqu...@googlegroups.com

In some cases (when creating only js-based mashup, for example) we unable to do it.

Allov

unread,
Mar 27, 2012, 10:24:52 AM3/27/12
to disqu...@googlegroups.com
I recently switched to this approach myself with no success. Now, I answer and redirect people that access http://example.com/some-url-slug to http://example.com/#!/some-url-slug, but Disqus is still unable to make a request. Disqus seems to try and request a page at the url WITHOUT the hashbang, but is receiving a 400 bad request from the server. I don't know what it's doing on the background, but just simply doesn't work. 

Anyone got a success story here?

neoascetic

unread,
Mar 27, 2012, 8:04:16 PM3/27/12
to disqu...@googlegroups.com
Look at your webserver logs. In my case, Disqus trying to request resource specified in `disqus_url` variable (with hashbangs), but this request go to webserver, which drop fragment part of URI (by RFC, fragment is not even part of URI). When user trying to request this URL, browser asks for URL without fragment, and then work with fragment with JavaScript.
So, in my opinion, you need to point `disqus_url` to URL without hashbang, if you don't do it before.

Allov

unread,
Mar 28, 2012, 3:35:25 PM3/28/12
to disqu...@googlegroups.com
Yes, if you read my post, that's exactly what I'm doing, I'm sending an URL without hash in the disqus_url. But, there is a redirect (302) being done, so maybe it's the problem. But, if you read Disqus doc, it's stated that you can use hashbangs for URLs, and "resetting" done by DISQUS.reset() function.
Reply all
Reply to author
Forward
0 new messages