$.fn.serializeForJSON = function()
        {
            var o = {};
            var a = this.serializeArray();
            $.each(a, function() {
                if (o[this.name] !== undefined) {
                    if (!o[this.name].push) {
                        o[this.name] = [o[this.name]];
                    }
                    o[this.name].push(this.value || '');
                } else {
                    o[this.name] = this.value || '';
                }
            });
            return o;
        };


  $.ajax({
            type: "post",
            url: "*******",
            data: JSON.stringify($("#jxForm").serializeForJSON()),//$("#jxForm").serializeArray(),
            dataType: 'json',
            contentType: "application/json",
            success: function (rst) {
                console.log(rst);
                if (rst.code == 0) {
                    layer.msg(rst.msg, {time: 1000}, function () {
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                        parent.searchData();
                    });
                } else {
                    layer.msg(rst.msg, {time: 1000}, function () {
                    });
                }
            }
        });

form表单序列化转换JSON_经验分享