ajax传递复选框的参数,ajax将table复选框的数组值传递到后台

  • Post author:
  • Post category:其他


//头工具栏事件

table.on(‘toolbar(gv_SalesOrderInfo)’, function (obj) {

debugger;

var ItemId = [];

var checkStatus = table.checkStatus(obj.config.id); //获取table复选框的集合值

for (var i = 0; i < checkStatus.data.length; i++) {

ItemId.push(checkStatus.data[i].SalesOrderID);

}

var str = “{‘ItemId’:'” + ItemId + “‘}”;

var ItemJson = JSON.stringify(str);

debugger;

$.ajax({

type: “post”, //要用post方式

url: “MySalesOrder_New.aspx/SendCoupon”, //后台接收数据的路径

data: “{ItemJson:” + ItemJson + “}”,

contentType: “application/json; charset=utf-8”,

dataType: “json”,

async: false,

success: function (jsonResult) {

if (jsonResult.Code == 1) {

alert(“添加成功”);

$(target).parent().parent().find(“input”).attr(“disabled”, true);

} else {

alert(“添加失败”);

}

}

});

SendCoupon(obj);

});