1

I am using AJAX with hash in URL with prototypejs.

When I use following URL:

http://example.com/#/example/104?v=0&d=a&rpp=10

print_r( $_GET );  // output: array()

When I use following URL:

http://example.com/example/104?v=0&d=a&rpp=10

print_r( $_GET );  // output: Array ( [v] => 0 [d] => a [rpp] => 10 )

So my question why I am not able to get URL params when using hash in URL. How can I get it.

Thanks

2 Answers 2

5

The part after the # doesn't get sent to the server.

(Its original purpose was to refer to a piece of the document, so that a URL could load a document and then scroll to a particular section. You can see how sending it to the server would be irrelevant in that case.)

Sign up to request clarification or add additional context in comments.

3 Comments

rewite your # with something, depends on your app structure
ok. I am doing parent.location.hash = url; after completing ajax request. (here url is complete url passed to ajax request function).. How can I change this to remove # from URL without refreshing whole page...
@Awan: You can't. If you want to send the piece of the URL after the # to the server, you'll need to send it via an AJAX request.
2

Form your request like this:

var url = 'http://example.com/#/example/104?v=0&d=a&rpp=10';
new Ajax.Request(url, {
    parameters: url.match(/\?(.*)/)[1]
});

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.