client端:
function Save(){
var data_temp = convert_To_Json(checkbox_selected());
//alert(data_temp);
$.ajax({
type: "post",
contentType: "application/json",
url: WebServiceUrl + "/CreateOrder_CreateSO",
data: ‘{"list":‘ + data_temp + ‘,"Id":"0"}‘,
dataType: "json",
success: function (d) {
if (d.d == null || d.d == undefined) {
alert("Please Login");
window.location.href = "Login.html";
return;
}
alert(d.d);
},
error: function (e) { alert("Error"); }
});
}
function convert_To_Json(ar_data) {
var temp = "";
for (var i = 0; i < ar_data.length; i++) {
var ar_temp = ar_data[i];
temp += ‘{"Product":"‘ + ar_temp[0] + ‘","Set":"‘ + ar_temp[1] + ‘","Qty":"‘ + ar_temp[2] + ‘","Price":"‘ + ar_temp[3] + ‘"},‘;
}
temp = temp.substr(0, temp.length - 1);
temp = ‘[‘ + temp + ‘]‘;
return temp;
}
function checkbox_selected() {
var ar = document.getElementsByName("ckb_Product");
var ar_checked = new Array();
for (var i = 0; i < ar.length; i++) {
if (ar[i].checked) {
var temp = ar[i].parentNode.parentNode;//.children[3].children[0];
var prodct = $(temp.children[1]).html();
var set = $(temp.children[2]).html();
var Qty = $(temp.children[3].children[0]).val();
var Price = $(temp.children[4].children[0]).val();
var ar1 = new Array();
ar1.push(prodct);
ar1.push(set);
ar1.push(Qty);
ar1.push(Price);
ar_checked.push(ar1);
}
}
return ar_checked;
}
webservice端:
[WebMethod(EnableSession = true)]
public string CreateOrder_CreateSO(List<Set_Product_List> list, string Id)
{
string re_value = Id;
return re_value;
}
js+json+webservice(List<>作为参数),布布扣,bubuko.com