I was on my profile page just now, and I wanted to see my questions sorted by the amount of votes, so I clicked the votes button. However, the link did not go to my profile page, but rather to this API link.
3 Answers
This is expected value.
Let's look at a profile page for a second, I'll choose one at random:
Wow, who gave this Jerk all that rep?
Notice I've hovered over the newest
button. At the bottom of the screen, chrome is telling me this links to:
https://gaming.stackexchange.com/api/userquestions.html?userid=102&page=1&pagesize=10&sort=newest
If I open this in a new tab I can even see that page. This is the page that Arda was referring to.
Alright, cool, but let's dig deeper:
The button in question actually is an href to that page:
<a title="sort by creation date" href="/api/userquestions.html?userid=102&page=1&pagesize=10&sort=newest">newest</a>
But when I click it, I don't end up at that page. So what's going on here? Instead of taking me to the api page, my webbrowser seems to be taking me to:
https://gaming.stackexchange.com/users/102/tzenes#qpage_1-apage_1-qsort_newest-asort_votes
Which is where I expect to be.
To find out why this is happening, let's visit this page with javascript disabled
.
In addition to a big warning at the top saying: Gaming - Stack Exchange works best with JavaScript enabled
, now when I click the newest link I'm taking to the api page.
AHA! Jeff is doing some sneaky javascript to make sure I don't end up on the api page. That sneaky sneak, and when I turn off my javascript (or use a whitelist) all of a sudden I'm taken to the API page instead!
SUCCESS
So look at the javascript in question. Not very pretty. Jeff's a smart cookie and has minified his Javascript to decrease page load time. Luckily I have a Javascript un-minifier. Oooo, pretty.
Let's highlight some important chunks in the code:
function loadAnswers(b, a) {
loadUrl("/api/useranswers.html?pagesize=" + answersPageSize + "&userId=" + userId, "#answers-table", b, a)
}
and
$("#answer-pager a, #tabs-answer-user a").live("click", function () {
var b = parsePagedUrl(this.href);
loadAnswers(b.page, b.sort);
a.update({
apage: b.page,
asort: b.sort
});
$.history.load(a.toUrl());
return false
});
Looks like he's over loading the click function to instead use an Ajax call to retrieve the data. From the looks of it Jeff has so much faith in his API he's even making the call right to it to get the data! He then updates the tables, and even adds this into the history. Very chic
-
So the real question is a) What happened to the Javascript locally, and b) Why does it link to the API in the first place? That said, I've been having problems with Javascript being quite slow to load on SE lately, it might be related.– user56Nov 15, 2010 at 4:12
-
As to A, that's specific to your computer. In respect to B, I've updated my answer– tzenesNov 15, 2010 at 5:38
-
@arda so you have problems with javascript on your computer. Great answer tzenes! Nov 15, 2010 at 12:43
-
@Jeff Still, the server should provide links to a non-Javascript version. This isn't a problem with Javascript on my computer, this is a problem of Javascript (and anything really) loading very, very slow on SE, which doesn't happen on any other site.– user56Nov 15, 2010 at 15:02
-
@Arda I did some spot tests in Europe and I was getting 2-3 second load times with the relevant javascript being delivered in ~200ms. Where are you trying to load from? On an unrelated note, the server does provide a no-script tag to indicate the site will perform poorly without Javascript, the issue here seems to be last mile delivery, not Javascript being disabled.– tzenesNov 15, 2010 at 16:40
-
@tzenes @Jeff That's exactly what I was saying, it's last mile delivery. This is a 50 mbit connection from The Netherlands. All I'm saying really is that it's a bad user experience to have the default link to be a link to the API. Imagine if someone right-clicks it and chooses
Open in new tab
? Aren't they going to be as confused as I was?– user56Nov 15, 2010 at 20:20 -
@Arda that sounds more like a feature request. If you feel strongly about this, and it seems you do, maybe you should be opening a new question– tzenesNov 15, 2010 at 21:58
-
@tzenes Not really. I find that a link going to a wrong location unless it's used some time after loading and only by clicking it directly is a bug. However, since @Jeff seems to disagree with me I don't really see the point of opening another question.– user56Nov 16, 2010 at 6:10
-
@Arda don't you think you're being a little hard with him? He tried to get more information so he could get to the bottom of it; I don't think he doesn't see this as a bug, I think he doesn't see it. While guaranteeing that his site functions in the case of failure (and I define not having JS on the web as failure) may not be a top priority, this seems like something he can easily change to provide a level of fault tolerance. Then again, it may not be possible with how that page is constructed, its hard to say
unless you open a new question...
– tzenesNov 16, 2010 at 7:12 -
@Jeff Someone made the default link on there the API link. This must've been a concious decision, hence, it must serve some purpose (punishing people with slow connections possibly) and I would not want to interfere with that.– user56Nov 16, 2010 at 17:23
Starting with the next build, these links will work when opening in a new tab, etc. The user page should function the same as before, but be quite a bit cleaner behind the scenes, enjoy.
-- Nick Craver
What web browser? I have heard of this before, but we can never reproduce it.
-
This is Google Chrome. It is quite a weird bug.– user56Nov 14, 2010 at 11:37
-
-
@Jeff Honestly, I can't see it being a client-side thing, seeing as the source directly gives me the API links. It has to be something on the server.– user56Nov 14, 2010 at 17:35
-
@arda I can't reproduce this in chrome.. I'm clicking all over your user page both here on meta and on parent, and I get no such behavior. (In Chrome 7 latest) Nov 14, 2010 at 18:46
-
@Jeff Oh, I don't just get this on my user page, I get it on every user page, also when I'm logged out. This leads me to believe it's somehow related to my IP address or something, because I also get it on Firefox. It is, without a question, not a client-side issue. I get these links served by the server directly, regardless of browser, cookies, et cetera.– user56Nov 14, 2010 at 21:35
-
-
@Jeff Without knowing how these pages are assembled on the server side, I can't. Seeing as not even using a different browser/computer solves it, I can't imagine it being something I did.– user56Nov 14, 2010 at 22:42
-
api.gaming.stackexchange.com
, the source of the public documented API, but togaming.stackexchange.com/api
, which is apparently used behind the scenes to replace parts of the page without reloading the whole shebang.