解析form表单数据

//解析form表单数据
function parseFormData(params) {
    var args = new Object();
    for(var key in params){
        if(!params[key].name)
            continue;
        var pos = params[key].name.indexOf(".");
        if(pos == -1){
            args[params[key].name] = params[key].value;
        }else{
            var argName = params[key].name.substring(0, pos);
            var argSubName = params[key].name.substring(pos + 1);
            args[argName] = args[argName] || {};
            args[argName][argSubName] = params[key].value;
        }
    }
    return args;
}

 

posted @ 2015-04-15 10:11  幻星宇  阅读(809)  评论(0编辑  收藏  举报