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() { vari = 0, queryString = [], chunks = [], self = this; varencode = function(str) { str = str + ""; //if ($spaces) str = str.replace(/ /g, "+"); returnencodeURIComponent(str); }; |
Comment out if ($spaces) str = str.replace (//g, "+"); That line can
2. The case that value is empty
| 1234567891011 |
get: function(key){ vartarget = this.GET(key); if(typeof(target) == ‘boolean‘) return‘‘; if(is(target, Object)) return jQuery.extend(true, {}, target); elseif(is(target, Array)) returntarget.slice(0); returntarget;}, |
| 1 |
<div>加入 </div><p>if(typeof (target) == ‘boolean‘) </p><p>return‘‘; 即可 </p> |
Two-point problem of jQuery.query.js taking parameters