Home  >  Article  >  Web Front-end  >  jQuery.query.js Analysis of Two Problems in Taking Parameters_jquery

jQuery.query.js Analysis of Two Problems in Taking Parameters_jquery

WBOY
WBOYOriginal
2016-05-16 17:51:12809browse

1. When there are spaces in the parameter, the spaces in the value obtained are replaced with plus signs:
2. When the value of a certain key in the parameter does not exist, the value obtained is not empty/null but true.

I found a solution online, you can refer to it (whether there are other side effects have not yet been tested)

1. Change spaces into plus signs

in jQuery.query. js file, find the following code

Copy the code The code is as follows:

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 be

2. When the value is empty
Copy code The code is as follows:

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;
},

Join if (typeof (target) == 'boolean')return ' ';
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn