当前位置 : 主页 > 网络编程 > JavaScript >

数组格式下ajax回传

来源:互联网 收集:自由互联 发布时间:2021-06-28
gistfile1.txt serverDetail.outAccess = [ {"accessId":"2","status":"1"}, {"accessId":"3","status":"1"}]用以上格式进行ajax回传时,var serverDetail = {};var outAccess = [];var outAccess1 = [];var checkboxobj = $("#systemType input")
gistfile1.txt
serverDetail.outAccess = [                   
    {"accessId":"2","status":"1"},
    {"accessId":"3","status":"1"}
]

用以上格式进行ajax回传时,
var serverDetail = {};
var outAccess = [];
var outAccess1 = [];

var checkboxobj = $("#systemType input");
$.each(checkboxobj,function(index,item){
	outAccess1[index] = {};
	if($(this).prop("checked")==true){
	//	checkboxobj.status ="0";
		outAccess1[index].accessId = $(item).attr("id");
		outAccess1[index].status = "0";
	}else if($(this).prop("checked")==false){
	//	checkboxobj.status ="1";
		outAccess1[index].accessId = $(item).attr("id");
		outAccess1[index].status = "1";
	}else{}
})
serverDetail.outAccess = outAccess1;
网友评论