问题
I am using this plugin: http://plugins.jquery.com/project/query-object
The 'get' and 'toString' methods work fine, but the 'set', 'empty', and 'remove' methods do not work. In the author's demonstration, he only uses 'get' and 'toString', but in his example on the top of the page, he uses the rest of the "nice-to-have" methods.
Anyone run into this before?
Thanks.
回答1:
I tried the set
method, and it works just fine:
alert($.query.set("section", 5).set("action", "do").toString());
Output:
?section=5&action=do
回答2:
Functions like .set
return modified copy of original query-object. If you wish to modify existing object (for example one created using .load(string)
method), use .SET
method.
Modifying of query string is possible now using HTML5: search for window.history.pushState()
. Setting window.location.href
variable will result in reloading page.
来源:https://stackoverflow.com/questions/2906141/how-to-use-jquery-query-string-object-plugin-set-empty-remove-methods-not-wo