1

i want to get hash parameters value in my java script for example my url should be like that

www.example.com/#!mydata=data&myopt=option

i want to get mydata in variable which will be "data" as value, and myopt "option"

iam trying to implement google ajax cowling like here Google Code

and i have tried to implement jquery address

but with big fail so help me either by solving 1st part or give me simple walk through tutorial to implement jquery address to my ajax requests ,thank you

1 Answer 1

3

This piece of code will convert any well formed (i.e. properly url-encoded) request string into an object literal with values parsed.

var s = "#!mydata=data&myopt=option";
var o = {};

$.each(s.substr(2).split('&'), function(i, elem) {
   var parts = elem.split('=');
   o[parts[0]] = parts[1];
});

Then you can access values like o.myopt

UPDATE

Of course, to get the value from browser's address, you should use

var s = window.location.hash;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.