fixed space-encoding issue in ajax post

This commit is contained in:
Timothy Warren 2011-06-14 14:30:30 -04:00
parent e5eb8db027
commit 74af10d2cb

7
kis.js
View File

@ -44,7 +44,7 @@
var type = (isPost) ? "POST" : "GET"; var type = (isPost) ? "POST" : "GET";
url += (type === "GET") url += (type === "GET")
? "?" + this._serialize(data) ? "?" + this._serialize(data, true)
: ''; : '';
request.open(type, url); request.open(type, url);
@ -66,7 +66,7 @@
request.send(null); request.send(null);
} }
}, },
_serialize: function(data) _serialize: function(data, encode)
{ {
var pairs = []; var pairs = [];
@ -77,8 +77,11 @@
var value = data[name].toString(); var value = data[name].toString();
if(encode === true)
{
name = encodeURIComponent(name.replace(" ", "+")); name = encodeURIComponent(name.replace(" ", "+"));
value = encodeURIComponent(value.replace(" ","+")); value = encodeURIComponent(value.replace(" ","+"));
}
pairs.push(name + "=" + value); pairs.push(name + "=" + value);
} }