0

I am reading about making my ajax application crawlable. According to google's doc, i need to change my http requests using hash, so from:

http://www.example.com/get_data?param1=6

to

http://www.example.com/get_data#!param1=6

I honestly don't get how #! could be handled by my server and parameters taken. So this makes me thinking i have don't understood the general concept. How can i pass parameters using hashes instead of '?'

thank you

Morrisda
  • 1,380
  • 1
  • 11
  • 25
  • 1
    Afaik, you can't, at least not by using generic GET requests. The hash will not be transferred to the server. Please someone correct me in case I am wrong. – nilsole Apr 07 '14 at 14:09
  • Your server can't read the hash on the server. This is out dated technique. Learn about the history api – epascarello Apr 07 '14 at 14:09
  • not sure, but i think it would not handled by server side automatically, you must pass it by yourself using javascript methods. – Unstaged Apr 07 '14 at 14:09
  • 1
    so what google means while talking about this? – Morrisda Apr 07 '14 at 14:09
  • Maybe you can post a link to the Doc you are referring to. Thanks. :) – nilsole Apr 07 '14 at 14:11
  • >so what google means while talking about this? as I remember it is just advice from google to developers, who cares about SEO and correctly indexing their links, because simple hash site.com/page.php#somevar will be ignored by google – Unstaged Apr 07 '14 at 14:11
  • Not sure about the whole concept, but there are is some information about it at point 2 here in this doc: https://developers.google.com/webmasters/ajax-crawling/docs/getting-started – nilsole Apr 07 '14 at 14:14
  • If Google says to change a URI not containing a "#" to a URI containing a "#" then they are very very wrong. – Julian Reschke Apr 07 '14 at 14:54

1 Answers1

0

The hash is something handled exclusively by JavaScript, which then makes a normal Ajax request. This StackOverflow question gives you some info on how you can detect changes in the Hash using JavaScript. Once the hash has changed:

var queryString = window.location.hash.replace(/^#/, "");
var xhr = new XMLHttpRequest();
var url = "/foo?" = queryString;

xhr.onreadystatechange = function() {
    ...
};

xhr.open("GET", url);
xhr.send(null);
Community
  • 1
  • 1
Greg Burghardt
  • 17,900
  • 9
  • 49
  • 92