Recently in the project using JQuery.query.js this plug-in to the page URL transfer value, encountered the following two points problem:
1. The value taken when there is a space in the parameter is replaced by a plus sign: +
2. When the value of a key of a parameter does not exist, the value obtained is NOT null/null but true.
Found a solution on the Internet, you can refer to (whether there are other side effects of the temporary not experimental)
1. Space Change Plus +
Locate the following code in the JQuery.query.js file
1234567 |
toString:
function
() {
var
i = 0, queryString = [], chunks = [], self =
this
;
var
encode =
function
(str) {
str = str +
""
;
//if ($spaces) str = str.replace(/ /g, "+");
return
encodeURIComponent(str);
};
|
Comment out if ($spaces) str = str.replace (//g, "+"); That line can
2. The case that value is empty
1234567891011 |
get:
function
(key)
{
var
target =
this
.GET(key);
if
(
typeof
(target) ==
‘boolean‘
)
return
‘‘
;
if
(is(target, Object))
return jQuery.extend(
true
, {}, target);
else
if
(is(target, Array))
return
target.slice(0);
return
target;
},
|
1 |
<div>加入 </div><p> if ( typeof (target) == ‘boolean‘ ) </p><p> return ‘‘ ; 即可 </p> |
Two-point problem of jQuery.query.js taking parameters