Jquery提交数组ID 返回JSON数据处理

2716

在开发后台项目的时候遇到要jquery要提交多个数据 让后台进行处理,因为要获取父级层的数据所以用到了

parent.$(".aid:checked").map(function (i,e){return $(e).val()}).get().join(',')


$(document).on("click","#content-tj",function() {
            obj = $(this);
            _url = $(this).attr("url");
            _arrid = parent.$(".aid:checked").map(function (i,e){return $(e).val()}).get().join(',');
            _recom_target = $(".param:checked").map(function (i,e){return $(e).val()}).get().join(',');
            $.ajax({
                type      : "post",
                url       :   _url,
                dataType  : "json",
                data      :  {
                    arrid : _arrid,
                    recom_area : _recom_target,
                    recom_target: $(".recom_target:checked").attr("value"),
                    recom_mark: $(".recom_mark:checked").attr("value"),
                    recom_clear: $(".recom_clear:checked").attr("value")
                },
                success   :function (data) {               
                    if (data.status) {
                        obj.addClass('disabled');
                        layer.msg(data.error,{icon: 6,time:1500,offset:'100px'},function(){
                            obj.removeClass('disabled');
                            parent.location.reload();
                        });   
                    } else {
                        obj.addClass('disabled');
                        layer.msg(data.error,{icon: 5,time:1500,offset:'100px'},function(){
                            obj.removeClass('disabled');
                            parent.location.reload();
                        });
                    }
                }  
            })
        })
public function recommend () {
$arr_id = explode(",", I("request.arrid"));//ID
$arr_id = array_filter($arr_id);
$recom_area = array_filter($recom_area);
}

这样 就能只获取 到提交的ID 数据了!

玄玄博客 :http://www.blogxuan.com/