代码改变世界

请url请求转化成obj

2013-01-04 15:21  yangpan  阅读(247)  评论(0编辑  收藏  举报

var formatQuery=function(query){
var strs=query.split("&");
var theRequest = {};
for(var str in strs){
var p=strs[str].split("=");
theRequest[p[0]] = !theRequest[p[0]] ? p[1] : theRequest[p[0]] + ',' + decodeURI(decodeURI(p[1] || '')).replace(/\+/g, ' ');
}
return theRequest;
};