码迷,mamicode.com
首页 > Web开发 > 详细

js+json+webservice(List<>作为参数)

时间:2014-06-23 06:10:35      阅读:294      评论:0      收藏:0      [点我收藏+]

标签:get   string   os   set   html   cti   

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

js+json+webservice(List<>作为参数)

标签:get   string   os   set   html   cti   

原文地址:http://www.cnblogs.com/mrwei/p/3799677.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!