日期:2014-05-16 浏览次数:20347 次
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
var o = { a: 1, b: 2, c: 3, d: 4 }
var s = $.param(o);
alert(s)
var arr = s.split('&'), item;
var NO = {};
for (var i = 0; i < arr.length; i++) {
item = arr[i].split('=');
NO[item[0]] = item[1];
}
console.log(NO);
</script>
$.unparam = function(s) {
var t = s.split(/&
------解决方案--------------------
=/);
var r = {};
for(var i=0; i<t.length; i+=2) r[t[i]] = t[i+1];
return r;
}
x = $.unparam('a=5&b=6&c=7&d=8');输出 6
alert(x.b);