views:

48

answers:

1

Hi,

i'm implementing deep linking for my website.

I wonder, why jquery-address is unable just to set a query string, like this:

www.mywebsite.com?search=keyword

When i using

$.address.parameter("search", "keyword")

jquery-address sets follwing url:

www.mywebsite.com?search#/?keyword

Why, it doing so ?

I just need the plain old query string, like in my first example.

Help, please !

A: 

Those addresses use the hash, which is because they're meant for the client. If you want to manipulate the query string, you can use the query plugin. E.g.:

window.location.search = $.query.set('search', 'keyword');

EDIT:

If you wanted to make multiple changes, you could do, e.g.:

var newQuery = $.query.set('search', 'keyword');
// ...
newQuery = newQuery.set('another', 'value');
window.location.search = newQuery;
Matthew Flaschen
Thanks, it seems to be working with simple case of setting.But i have troubles with setting values, separated with comma. This code: window.location.search = $.query.set('search', 'keyword1, keyword2') produces the URL like this: www.mywebsite.com?search=keyword1%2C%2Bkeyword2. The %2C code is ok, because it is comma, but the %2B is strange, because it is "+" sign. So, it sets ?search=keyword1,+keyword2 instead of ?search=keyword, keyword2
AntonAL
`+` is used for space in [application/x-www-form-urlencoded](http://en.wikipedia.org/wiki/Percent-encoding#The_application.2Fx-www-form-urlencoded_type). However, I don't know if that URL is exactly correct.
Matthew Flaschen
Hmm. Setting window.location forces redirection to modified URL and reloading the page. Unfortunately, this way is not suitable for me ...
AntonAL
@Anton, you can not change the query string without forcing a load. That is why jquery-address (and other code) uses the hash (the part after the `#`). However, you can make multiple changes to the query string with a single load. I added an example of that.
Matthew Flaschen
Thanks. I've switched to use hash-values. Everything is working now.
AntonAL